[squeak-dev] a==b "true" but a=b "false"

Andres Valloud avalloud at smalltalk.comcastbiz.net
Thu Sep 4 19:42:43 UTC 2014


> Because non-a-numbers result from overflowing or underflowing
> computations, and hence, just because two computations produce the same
> not-a-number doesn't imply that the two computations are equivalent.
>   This is why the IEEE-754 standard requires that NaN != NaN.

Merely to expand on the subject, and notwithstanding the above...

This property of NaNs allows you to identify them quickly.  Unlike other 
entities such as +/- INF, you can test for a NaN with something like

   x = x ifFalse: ["then x is a NaN"]

Keep in mind that, also unlike +/- INF, there is a multitude of binary 
representations for NaN.  So, you can't necessarily do something like

   x as64BitInteger = nanExpressedAs64BitInteger

because it will most likely fail.

Andres.


More information about the Squeak-dev mailing list