[BUG] Float NaN's

Travis Griggs tgriggs at key.net
Tue Sep 14 05:41:39 UTC 2004


On Sep 13, 2004, at 12:57, Boris Gaertner wrote:

>
>
>  "Chris Muller" <afunkyobject at yahoo.com> wrote:
>  > Oops, I retyped the example in my email and should've cut and 
> pasted.
>  Here is
>  > what I meant:
>  >
>  >   (Dictionary new at: Float nan put: 'nan'; yourself) printString
> >
>  > Also, I'm interested in your commentary on the first example too..
>  >
>  >   (Set with: Float nan) includes: Float nan    "false"
>  >
>  > do you think these are bugs?
>  >
>
> No, I think these are not bugs.
> First, this has nothing to do with Sets and Dictionaries,
> it is a property of Float.
>
> First, try this:
>
>   Float nan = Float nan
>
> You obtain false. At first sight, this is a surprise, but it is 
> possible
>  to defend this result with good reasons. Look at this:
>
> 1.0e200 tan = 1.0e200 tan
>
> gives false and
>
>   1.0e200 tan = 1.0e200 sin
>
> gives also false.
>
> This last example is the key to a better understanding
> of the properties of NaNs. A NaN represents the result
> of a computation that can not be represented as a
>  Float value. As we can certainly not say that
>    1.0e200 sin   and  1.0e200 tan
>  are equal, it is best to assume that two
>  NaNs are never equal. (Database progammers
> will remember similar rules for NULL values.
>  Two NULL values are never considered to be
>  equal, simply because the represent unknown
> entities).
>
> Form the Intel documentation of instruction
> FCOm (Float COMpare)
>
> >>If either operand is a NaN or is in an unsupported
> >>format, an invalid-arithmeticoperand exception (#IA)
>  >>is raised and, if the exception is masked, the condition
> >>flags are set to "unordered." If the invalid-arithmetic-
> >>operand exception is unmasked, the condition code
>  >>flags are not set.
>
>
>
> This means that NaNs are never considered to be
>  equal.

I remember researching this to try and get VW up to date w.r.t. ieee fp 
math and learning something interesting things about NAN. It is the 
singularity event horizon of fp math. Any math you do with it will turn 
into a NAN. Even +/-infs. All roads lead to NAN. And when you get 
there, it refuses to be "truth"ful about anything. It is not = to 
itself or anything else for that matter. It gets better. It's not 
greater or less than itself. Or anything else. Greater than or equal 
and the flip don't work either. The thing is the "false" hole.

--
Travis Griggs
Objologist
One man's blue plane is another man's pink plane.


-----------------------------------------
DISCLAIMER: This email is bound by the terms and conditions described at
http://www.key.net/disclaimer.htm




More information about the Squeak-dev mailing list