nan question

Don Clugston dac at nospam.com.au
Wed Sep 26 03:07:13 PDT 2007


Janice Caron wrote:
> Think of NaN as meaning "I don't know the answer".
> 
> With that understanding, when you compare two NaNs with ==, you are
> asking "Is one thing I don't know the answer to equal to another thing
> I don't know the answer to". The absolutely correct answer should
> really be "I don't know, but probably not", but since that can't be
> expressed in a bool, we go with the second best answer: no.

Yes, we're forcing 3 states (yes, no, maybe) into 2 states.
IMHO, it would have been better to retain the crucial identity x==x, rather than 
try to detect obscure floating-point bugs. (and introduce a different operator 
to mean, equal-and-not-both-NaN).

I use NaNs a lot (probably more than anyone else on this ng), and have not found 
many cases where the IEEE behaviour is helpful.



More information about the Digitalmars-d mailing list