int nan

bearophile bearophileHUGS at lycos.com
Fri Jun 26 12:26:01 PDT 2009


The following comes partially from a friend of mine. If you are busy you can skip this post of musings.

>From the docs:
http://www.digitalmars.com/d/1.0/faq.html#nan
>Because of the way CPUs are designed, there is no NaN value for integers, so D uses 0 instead. It doesn't have the advantages of error detection that NaN has, but at least errors resulting from unintended default initializations will be consistent and therefore more debuggable.<

Seeing how abs(int.min) gives problems, and seeing how CPUs manage nans of FPs efficiently enough, it can be nice for int.min to become the nan of integers (and similar for short, long, and maybe tiny too). Such nan may also be useful for purposes similar to nullable integers of C#.

Bye,
bearophile



More information about the Digitalmars-d mailing list