On 11/12/2013 12:24 PM, Andrei Alexandrescu wrote:
You're young. I guarantee you were to hit NaN whether or not D had anything to
do with it.

I want to add that NaN has been a reality on x86 machines since about 1983. C (and C++) compilers for decades have utterly ignored its existence - but that didn't make it go away. It just meant that things like the fp functions in the Standard library exhibited undefined behavior with NaNs, which is far worse than at least having sensible documented behavior.

The C compilers I wrote (and C++) always made an effort to handle NaN correctly (and overflows, underflows, and subnormals), and I often felt that I was the only one who cared about it :-)

What D does is simply recognize that NaNs are an inevitable characteristic of the floating point hardware, and deal with them in the most straightforward manner practical. Deciding and documenting what .sort should do with NaNs is part of that. Trying to pretend that NaNs aren't a fact of life with IEEE floating point hardware is not going to work.

Note:

http://dlang.org/phobos/std_math.html#.exp

and how the behavior with NaN arguments is all carefully documented.

Reply via email to