NaNs Just Don't Get No Respect

Peter Alexander peter.alexander.au at gmail.com
Mon Aug 20 14:07:59 PDT 2012


On Monday, 20 August 2012 at 20:21:12 UTC, cal wrote:
> I just tried this:
>
> float a, b = 10;
> writeln(min(a, b), ", ", fmin(a, b));
>
> Result:
> nan, 10
>
> I think that is incorrect - both should give NaN. The 
> scientific viz software I use at work returns NaN for any 
> numerical operation on NaN values, means, smoothing, etc.

It's tricky. The only way (that I'm aware of) to get it to return 
NaN is to explicitly test for NaN, introducing overhead that is 
unnecessary 99.9% of the time.

Unfortunately this is one of those situations where D's design 
goals of efficiency and safety are at odds. You can't have it 
both ways.


More information about the Digitalmars-d-announce mailing list