How to test if float is NaN?

xs0 xs0 at xs0.com
Wed May 17 01:29:48 PDT 2006


clayasaurus wrote:
> How do you test if float is Nan? == and is doesn't seem to work.
> 
> float num;
> if (num ==/is float.nan)
> {
> // true
> }
> else
> {
> // false
> }
> 
> ?

I think this should work as well:

if (num == num) {
     // not NaN
} else {
     // NaN
}


xs0



More information about the Digitalmars-d-learn mailing list