Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 16 04:43:14 PDT 2016


On 5/16/2016 3:30 AM, Andrei Alexandrescu wrote:
> On 5/16/16 3:31 AM, Walter Bright wrote:
>>
>> Ironically, this Microsoft article argues for greater precision for
>> intermediate calculations, although Microsoft ditched 80 bits:
>>
>> https://msdn.microsoft.com/en-us/library/aa289157(VS.71).aspx
>
> Do you have an explanation on why Microsoft ditched 80-bit floats? -- Andrei

At the time they were porting NT to some other architecture which didn't have 80 
bits. I suspect they dumped it in order to enhance code compatibility between 
the x86 compiler and the other compiler. I think Microsoft tools had an internal 
mandate to make the differences between the machines as small as possible.

The lack of 80 bit SIMD support likely gave it a good shove off the curb as 
well. Even dmd no longer generates x87 code for float/double for 64 bit targets, 
meaning no more 80 bit temporaries.

It's kinda sad, really. The x87 was a triumph of engineering when it came out. 
The comments that "64 bits is all anyone will ever need" are not made by people 
who do numerical work, where one constantly battles catastrophic loss of precision.

I've often wondered how NASA calculates trajectories out to Jupiter, because it 
has to be done iteratively, and that means cumulative loss of precision. I wrote 
some orbit software for fun in college, and catastrophic loss of precision would 
make the orbits go completely bonkers after just one orbit. I invented several 
schemes to fix it, but nothing worked.

When I was doing numerical analysis for my you-know-what job, I had to invert 
matrices all the time. I only knew the math algorithm, and that would produce 
nonsense on anything larger than 14*14 or so using doubles. Better algorithms 
exist that compensate for the errors, but this was pre-internet and I didn't 
know where to get such a solution.

Those two experiences shaped my attitudes about the value of precision, as well 
as the TTL boards I designed where the design had to still work if faster parts 
were swapped in.


More information about the Digitalmars-d mailing list