Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun May 15 14:01:14 PDT 2016


On 5/15/2016 11:45 AM, Ola Fosheim Grøstad wrote:
> On Sunday, 15 May 2016 at 18:35:15 UTC, Walter Bright wrote:
>> On 5/15/2016 1:33 AM, Ola Fosheim Grøstad wrote:
>>> That is _very_ bad.
>>
>> Oh, rubbish. Did you know that (x+y)+z is not equal to x+(y+z) in floating
>> point math? FP math is simply not the math you learned in high school. You'll
>> have nothing but grief with it if you insist it must be the same.
>
> Err... these kind of problems only applies to D.

Nope. They occur with every floating point implementation in every programming 
language. FP math does not adhere to associative identities.

   http://www.walkingrandomly.com/?p=5380

   http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

Ironically, the identity is more likely to hold with D's extended precision for 
intermediate values than with other languages.


More information about the Digitalmars-d mailing list