'From Squeak3.7beta of ''1 April 2004'' [latest update: #5923] on 1 October 2004 at 6:41:18 pm'! "Change Set: FloatTestPatch-3-dtl Date: 28 September 2004 Author: David T. Lewis This is a replacement for the #testNaN2 test. Rather than using the trig libraries to produce different NaN values (the libraries seem to be different on different platforms), a copy of Float nan is used and its bit are twiddled to produce different bit patterns. This should work on all platforms (little endian and big endian), and it documents the intended behavior of ''two NaN values are always considered to be different, even if their bit patterns are the same.'' This change set should be applied after the FloatTest-additionalTests change set that Boris originally posted. In addition to the #testNaN2 replacement, it corrects a minor typo in another test method. "! !FloatTest methodsFor: 'NaN behavior' stamp: 'dtl 10/1/2004 18:26'! testNaN2 "Two NaN values are always considered to be different. On an little-endian machine (32 bit Intel), Float nan is 16rFFF80000 16r00000000. On a big-endian machine (PowerPC), Float nan is 16r7FF80000 16r00000000. Changing the bit pattern of the first word of a NaN produces another value that is still considered equal to NaN. This test should work on both little endian and big endian machines. However, it is not guaranteed to work on future 64 bit versions of Squeak, for which Float may have different internal representations." "FloatTest new testNaN2" | nan1 nan2 | nan1 := Float nan copy. nan2 := Float nan copy. "test two instances of NaN with the same bit pattern" self deny: nan1 = nan2. self deny: nan1 == nan2. self deny: nan1 = nan1. self assert: nan1 == nan1. "change the bit pattern of nan1" self assert: nan1 size == 2. self assert: (nan1 at: 2) = 0. nan1 at: 1 put: (nan1 at: 1) + 999. self assert: nan1 isNaN. self assert: nan2 isNaN. self deny: (nan1 at: 1) = (nan2 at: 1). "test two instances of NaN with different bit patterns" self deny: nan1 = nan2. self deny: nan1 == nan2. self deny: nan1 = nan1. self assert: nan1 == nan1 ! ! !FloatTest methodsFor: 'zero behavior' stamp: 'dtl 9/26/2004 10:19'! testZero1 "FloatTest new testZero1" self assert: Float negativeZero = 0 asFloat. self assert: (Float negativeZero at: 1) ~= (0 asFloat at: 1). " The negative zero has a bit representation that is different from the bit representation of the positive zero. Nevertheless, both values are defined to be equal. " ! !