Is D floating point semantics too advanced?
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sun Aug 26 13:22:25 PDT 2007
Sean Kelly wrote:
> 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
Why would it be inconsistent? Because the equality contract states that
anything that has the same identity, should also compare equal?
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list