Mantis - Squeak
Viewing Issue Advanced Details
6719 Kernel minor always 10-10-07 20:32 04-18-10 22:04
nicolas cellier  
nicolas cellier  
normal  
closed 3.10  
fixed  
none    
none trunk  
0006719: Float nan comparison is broken
IEEE 754 state that NaN cannot be compared (ordered)
Thus every comparison message involving a NaN SHOULD return false.

This is not the case for example of:
  Float nan >= 2
Which is true, and should be false...
In old versions when NaN were not in the image, Float used to be a fully ordered set and as such were a good subclass of Magnitude.

With NaN inside, this is not the case anymore. This is breaking original st80 logic.

I would prefer converting Float nan to some NaN instance.
A class that would of course not even be a kindOf: Number as the name tells (Not A Number).
related to 0007260closed lewis some Float comparison primitives don't handle Nan correctly 
 FloatNaNCompare-M6719-Test.1.cs [^] (1,453 bytes) 10-10-07 21:16
 FloatNaNCompare-M6719-Test.2.cs [^] (2,139 bytes) 10-10-07 22:05
 M6719-FloatNaNCompare-Patch-nice.1.cs [^] (3,292 bytes) 01-04-09 23:13

Notes
(0011290)
nicolas cellier   
10-10-07 22:07   
Mea culpa: one comparison operator should return true.
This is the ~= test.
So please forget FloatNan-Compare-M6719-Test.1.cs and load version 2.
(0012889)
nicolas cellier   
01-04-09 20:11   
I have some in-image correction to propose, but that will not fully solve the problem...
The VM must also be corrected 0007260
(0012897)
nicolas cellier   
01-04-09 23:20   
A) Magnitude assumes subclass are fully ordered sets
B) Number is a partially ordered set due to nan

Thus Number is not a well behaved Magnitude...

Either we relax Magnitude assumption, by changing definition of <= and >=,
Or we implement > >= <= in Number or its subclasses to avoid the nan mess.

I propose to adopt second solution, based on 0003374, that is based on exact number comparison.
If you don't like 0003374 , simply replace adpatToXXX:andCompare: with adpatToXXX:andSend:

Note that VW does encounter the problem with Point comparison.
In Squeak too, but we should better forbid such comparison see 0007259

And please, don't forget that a new VM is also needed ( 0007260 )
(0012898)
nicolas cellier   
01-04-09 23:21   
"fix begin"
Installer mantis ensureFix: 3374.
Installer mantis bug: 6719 fix:'M6719-FloatNaNCompare-Patch-nice.1.cs'.
"fix test"
Installer mantis bug: 6719 fix:'FloatNaNCompare-M6719-Test.2.cs'.
"fix end"
(0012901)
nicolas cellier   
01-04-09 23:33   
Note that another solution would be to test

    argument isNumber ifFalse: [^false]

for every comparison (< <= > >=), a l'instar de #=
(0013352)
nicolas cellier   
10-05-09 19:25   
Fixed in http://source.squeak.org/trunk/Kernel-nice.250.mcz [^]
Note: the fix does not include 0003374 by now.
This will be an independent decision (I will strongly support of course)