[BUG] Float NaN's] (reposting Boris' test for BFAV to pick up)

Tim Olson tim at io.com
Fri Oct 1 13:52:24 UTC 2004


> "stéphane ducasse" <ducasse at iam.unibe.ch> wrote:
>
>
>> hi guys
>>
>> Could one of you write a bunch of tests to record the correct behavior
>> and add as comment
>> the discussion of this email?
>>
>> Stef
>
> Attached you find a change set that contains additional tests for the
> class FloatTest.
> Comments are welcome.
>
> Greetings, Boris

Hi, all:

I was temporarily bumped off the mailing list distribution, so I didn't 
see the flurry of Float NaN postings until now.  I implemented the 
original "IEEE-ification" of the Float class, adding the NaNs, 
Infinities, stable printing, etc.  The interaction of NaNs with Sets 
and Dictionary keys was a surprise, but it is interesting that it 
hadn't been discovered until recently (6+ years after the addition of 
NaNs with the behavior x == x, x ~= x).

Some comments on Boris' tests:

testNan2 is not portable; there is no reason for any particular 
floating-point library implementation to return NaN for sin / tan of 
values greater than 1e200.  That is simply an artifact of Intel's x86 
trancendental range reduction implementation.

You might also add a test for the difference of same-signed Infinities 
returning NaN:

	Inf - Inf -> NaN
	Inf + -Inf -> NaN


In the testZero1 test:

   self assert: (Float negativeZero at: 1) ~= (0 asFloat at: 1).

This can be written more understandably as:

	Float negativeZero sign ~= 0 sign.

Additionally, you could add a testSign test which verified that sign 
works as above.

	-- Tim Olson




More information about the Squeak-dev mailing list