Is D floating point semantics too advanced?
Sean Kelly
sean at f4.ca
Sun Aug 26 09:46:56 PDT 2007
Walter Bright wrote:
> Hans-Eric Grönlund wrote:
>> I've written a post on my blog wondering if the floating point
>> semantics is too advanced. The problem I have with it is that I can't
>> write something like this:
>>
>> if (someValue == real.nan) {...}
>>
>> It will never be true, which - for me - is unintuitive.
>
> The behavior is as specified by the floating point standard IEEE 754. To
> change it would break from FORTRAN, C and C++ usage in a way that would
> silently break code that is transliterated.
It would be a horrible inconsistency, but the 'is' operator could be
made to return true in this instance. After all, 'is' tests identity,
not equality.
Sean
More information about the Digitalmars-d
mailing list