Re: Floating point init/nan

2014-02-15 Thread Jonathan M Davis
On Saturday, February 15, 2014 05:28:05 Adam D. Ruppe wrote: > On Saturday, 15 February 2014 at 05:18:51 UTC, Adam S wrote: > > assert(float.init == float.nan); > > nan never equals nan, this is in the floating point spec used by > D, C and others. To be more precise, NaN is never equal to _anyth

Re: Floating point init/nan

2014-02-14 Thread bearophile
Adam D. Ruppe: nan never equals nan, Additionally, the init NaN doesn't have the same bitpattern as the other. There are many NaNs. Bye, bearophile

Re: Floating point init/nan

2014-02-14 Thread Adam D. Ruppe
On Saturday, 15 February 2014 at 05:18:51 UTC, Adam S wrote: assert(float.init == float.nan); nan never equals nan, this is in the floating point spec used by D, C and others. Use this instead: http://dlang.org/phobos/std_math.html#isNaN

Floating point init/nan

2014-02-14 Thread Adam S
I seem to be having some difficulty with the nan and init properties of floating point types. Can anyone explain why the following assertions all fail: assert(float.init == float.nan); assert(float.nan == float.nan); assert(float.init == float.init); Thanks.