[Info-vax] Where is EISNER:: and who funds it?

Arne Vajhøj arne at vajhoej.dk
Tue Dec 28 14:36:48 EST 2021


On 12/28/2021 11:54 AM, Simon Clubley wrote:
> On 2021-12-26, Arne Vajhøj <arne at vajhoej.dk> wrote:
>> On 12/26/2021 5:48 AM, Simon Clubley wrote:
>>> On 2021-12-25, Dave Froble <davef at tsoft-inc.com> wrote:
>>>> As far as that goes, so is Fahrenheit with either.  It's just a multiplier and
>>>> an offset.
>>>>
>>>> A couple of lines from a simple VB program I have:
>>>>
>>>>        C = (F - 32) * 5 / 9
>>>>        F = C * 9 / 5 + 32
>>>
>>> I looked at the above two statements and basically went "eek!" at
>>> all the implicit type conversions potentially going on above. :-)
>>>
>>> Does VB do the right thing above or do variables F and C get
>>> type converted to an integer (with loss of information) before
>>> the above calculations are done ?
>>>
>>> Just curious. (In situations like that, I would have written the
>>> integers with a decimal component, so 32 would become 32.0 for example.)
>>
>> VMS Basic behaves like most other languages.
>>
>> If the input variable is integer then it does integer math.
>>
>> If the input variable is floating point then it does floating point math.
>>
>> And it produces expected result if input variable and output
>> variable are same type.
>>
>> Only if input is integer and output is floating point it is
>> necessary to do something to change the math from integer math
>> to floating point math.
> 
> I've hit cases in the past with at least one language (I can't remember
> which) where integer constants used with a floating point variable would
> give a different result than FP constants used with a FP variable.
> 
> As a result, I would now write "C = (F - 32) * 5 / 9" if I am working
> with integer variables and "C = (F - 32.0) * 5.0 / 9.0" if I am working
> with decimal/float variables.
> 
> That's why the use of integers with (presumed) FP variables stood
> out above... :-)

If a compiler sees:

fpvalue operator intvalue

then I would expect it to either:
- lossless convert the intvalue to a floating point value
or:
- give an error about invalid mixing of fp and int

Doing a lossy conversion of fpval to integer value would be very bad.

I don't think I have ever encountered such a language, but it could
of course exist - there are a lot of weird languages out there.

Arne




More information about the Info-vax mailing list