Mantis - Squeak
Viewing Issue Advanced Details
6983 Kernel minor always 03-14-08 22:37 04-18-10 22:05
nicolas cellier  
nicolas cellier  
closed 3.10  
none trunk  
0006983: Float nan isLiteral. It should not.
There is no way to store Float nan as a literal.
(Yes there is one, but there should not. It is a bug of Number>>readFrom:, see 0006982)


self assert: (Compiler evaluate: Float nan storeString) isNan.

self assert: (Compiler evaluate: (Array with: Float nan) storeString) first isNan.
I have an easy and cheap way to define isLiteral which is synonym of isFinite:

^(self - self) isZero
 FLoat-isLiteral-Test-M6983-nice.1.cs [^] (471 bytes) 03-14-08 22:49
 Float-isLiteral-Patch-M6983-nice.1.cs [^] (789 bytes) 03-14-08 22:50

nicolas cellier   
03-14-08 22:55   
Note that there are still literal representation of Float infinity, like 1.0e1000.

However, since Float infinity is not able to print literaly, and isLiteral is intended for print, i think it's better to answer false for infinite Floats too.

Unless you really like (Array with: Float infinity) to be printed #(1.0e1000) ?
nicolas cellier   
03-15-08 00:28   
Note that the patch does not solve storeString bugs indicated above.
See 0001631 for a possible solution.

(Array with: Float nan) storeString ->
 '((Array new: 1) at: 1 put: NaN; yourself)'

A side effect is that Float nan and Float infinity are no more selfEvaluating...
(which is true until 0001631 is fixed).
nicolas cellier   
01-04-09 22:34   
"fix begin"
Installer mantis bug: 6983 fix:'Float-isLiteral-Patch-M6983-nice.1.cs'.
"fix test"
Installer mantis bug: 6983 fix:'FLoat-isLiteral-Test-M6983-nice.1.cs'.
"fix end"
nicolas cellier   
08-24-09 20:20   
Fixed in [^]