Can we drop casts from float to bool?

bearophile bearophileHUGS at lycos.com
Wed Mar 24 07:56:14 PDT 2010


Don:
>Sometimes NaNs are true, sometimes not!<

Urg.


> That won't work in this case, unless you make nan a keyword. There are 
> 2^^62 different NaNs, so a bitwise comparison will not work.

You are right, I did forget that here.
So I have modified a little my request:
http://d.puremagic.com/issues/show_bug.cgi?id=3981

"x is double.init" can be used to detect uninitialized variables, because in this proposal "is" performs a bitwise comparison (this makes "is" not that useful with structs).

The syntax "x == nan" can be used to perform the smart comparison with all possible nans. But this is an uncommon operation, so isnan(x) is good enough.

Bye and thank you for your insights,
bearophile



More information about the Digitalmars-d mailing list