added #isNaN
authorClaus Gittinger <cg@exept.de>
Wed, 12 Feb 1997 16:49:38 +0100
changeset 2387 3aafb49a86ac
parent 2386 b499ac8389c1
child 2388 df5e0eb88999
added #isNaN
Float.st
SFloat.st
ShortFloat.st
--- a/Float.st	Wed Feb 12 15:31:30 1997 +0100
+++ b/Float.st	Wed Feb 12 16:49:38 1997 +0100
@@ -110,6 +110,17 @@
 "
 ! !
 
+!Float class methodsFor:'initialization'!
+
+initialize
+    DefaultPrintFormat := '.6'	"/ 6 valid digits
+
+    "
+     DefaultPrintFormat := '.9' 
+     DefaultPrintFormat := '.6' 
+    "
+! !
+
 !Float class methodsFor:'instance creation'!
 
 basicNew
@@ -278,17 +289,6 @@
     "Modified: 23.4.1996 / 09:27:15 / cg"
 ! !
 
-!Float class methodsFor:'initialization'!
-
-initialize
-    DefaultPrintFormat := '.6'	"/ 6 valid digits
-
-    "
-     DefaultPrintFormat := '.9' 
-     DefaultPrintFormat := '.6' 
-    "
-! !
-
 !Float class methodsFor:'queries'!
 
 isBuiltInClass
@@ -1033,6 +1033,19 @@
 
 !Float methodsFor:'testing'!
 
+isNaN
+    "return true, if the receiver is an invalid float (NaN - not a number).
+     These are not created by ST/X float operations (they raise an exception);
+     however, inline C-code could produce them ..."
+
+%{  /* NOCONTEXT */
+
+    static double nan = 0.0 / 0.0;
+
+    RETURN (__floatVal(self) == nan);
+%}
+!
+
 negative
     "return true if the receiver is less than zero"
 
@@ -1289,5 +1302,6 @@
 !Float class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.48 1997-02-01 20:11:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.49 1997-02-12 15:49:38 cg Exp $'
 ! !
+Float initialize!
--- a/SFloat.st	Wed Feb 12 15:31:30 1997 +0100
+++ b/SFloat.st	Wed Feb 12 16:49:38 1997 +0100
@@ -528,6 +528,20 @@
 
 !ShortFloat methodsFor:'testing'!
 
+isNaN
+    "return true, if the receiver is an invalid float (NaN - not a number).
+     These are not created by ST/X float operations (they raise an exception);
+     however, inline C-code could produce them ..."
+
+%{  /* NOCONTEXT */
+
+    static float nan = 0.0 / 0.0;
+
+    RETURN (__floatVal(self) == nan);
+%}
+
+!
+
 negative
     "return true if the receiver is less than zero"
 
@@ -562,5 +576,5 @@
 !ShortFloat class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SFloat.st,v 1.12 1996-11-05 18:39:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SFloat.st,v 1.13 1997-02-12 15:49:25 cg Exp $'
 ! !
--- a/ShortFloat.st	Wed Feb 12 15:31:30 1997 +0100
+++ b/ShortFloat.st	Wed Feb 12 16:49:38 1997 +0100
@@ -528,6 +528,20 @@
 
 !ShortFloat methodsFor:'testing'!
 
+isNaN
+    "return true, if the receiver is an invalid float (NaN - not a number).
+     These are not created by ST/X float operations (they raise an exception);
+     however, inline C-code could produce them ..."
+
+%{  /* NOCONTEXT */
+
+    static float nan = 0.0 / 0.0;
+
+    RETURN (__floatVal(self) == nan);
+%}
+
+!
+
 negative
     "return true if the receiver is less than zero"
 
@@ -562,5 +576,5 @@
 !ShortFloat class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.12 1996-11-05 18:39:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.13 1997-02-12 15:49:25 cg Exp $'
 ! !