nan question
BCS
ao at pathlink.com
Tue Sep 25 08:38:51 PDT 2007
Reply to bobef,
> Hello,
>
> I have a little question.
> This program outputs gggg on dmd 1.21. Yes, I suck at math, but is
> this right (i.e. buggy) or nans must be compared another way?
> ===========================
>
> import tango.io.Stdout;
>
> void main()
> {
> double a=double.nan;
> if(a==double.nan) Stdout("1\n");
> else Stdout("g\n");
> if(a is double.nan) Stdout("2\n");
> else Stdout("g\n");
> if(double.nan==double.nan) Stdout("3\n");
> else Stdout("g\n");
> if(double.nan is double.nan) Stdout("4\n");
> else Stdout("g\n");
> }
if you want to check for nan without a function call uses: fpVar !<>= 0
More information about the Digitalmars-d
mailing list