[BUG] Float NaN's

Tim Rowledge tim at sumeru.stanford.edu
Mon Sep 13 19:40:11 UTC 2004


In message <20040913184552.9972.qmail at web52609.mail.yahoo.com>
          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

D'oh! Missing #new. With the new I get a 'key not found' notifier. The
debugger shows the NaN ok and I can inspect it. Oddly enough the result
of findElementOrNil: is 4, whereas in my dictionary the NaN is at 3...
The starting index calculated in Dictionary scanFor: is ok (3). Ah -
the key of the element 3 (which appears as NaN->'nan') does NOT #= the
anObject (which is supposed to be NaN). 
> 
> Also, I'm interested in your commentary on the first example too..
> 
>   (Set with: Float nan) includes: Float nan    "false"
It's going to be the same issue - comparing Nan with Nan fails.

Since all the code eventually boils down to
primitiveFloatEqualtoArg(int rcvrOop, int argOop) {
    double rcvr;
    double arg;

	rcvr = loadFloatOrIntFrom(rcvrOop);
	arg = loadFloatOrIntFrom(argOop);
	if (foo->successFlag) {
		return rcvr == arg;
	}
}
I guess it depends on how double = is supposed to work with a NaN
value.
Try
	Float nan = Float nan
I get false. Float nan == Float nan is true of course since they are
the same object.

> 
> do you think these are bugs?
Looks like it to me, but where? IEEE float standard? Our float code? Cs
float code?

tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Strange OpCodes: SCEU: Simulate Correct Execution, Usually



More information about the Squeak-dev mailing list