#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 20 Jun 2017 13:54:48 +0200
changeset 21857 76798ae913d1
parent 21856 8a95e50f7005
child 21858 5ae229caf43e
#FEATURE by cg class: LongFloat class definition class: LongFloat class added: #NaN #infinity #negativeInfinity
LongFloat.st
--- a/LongFloat.st	Tue Jun 20 13:36:16 2017 +0200
+++ b/LongFloat.st	Tue Jun 20 13:54:48 2017 +0200
@@ -15,7 +15,8 @@
 
 LimitedPrecisionReal variableByteSubclass:#LongFloat
 	instanceVariableNames:''
-	classVariableNames:'DefaultPrintFormat LongFloatZero LongFloatOne Pi E Epsilon'
+	classVariableNames:'DefaultPrintFormat LongFloatZero LongFloatOne Pi E Epsilon NaN
+		PositiveInfinity NegativeInfinity'
 	poolDictionaries:''
 	category:'Magnitude-Numbers'
 !
@@ -512,6 +513,21 @@
 
 !LongFloat class methodsFor:'constants'!
 
+NaN
+    "return a longFloat which represents not-a-Number (i.e. an invalid number)"
+
+    NaN isNil ifTrue:[
+        NaN := super NaN
+    ].
+    ^ NaN
+
+    "
+     LongFloat NaN
+    "
+
+    "Created: / 20-06-2017 / 13:52:58 / cg"
+!
+
 e
     "return the constant e as LongFloat"
 
@@ -524,6 +540,36 @@
     ^ E
 !
 
+infinity
+    "return a shortFloat which represents positive infinity"
+
+    PositiveInfinity isNil ifTrue:[
+        PositiveInfinity := Float infinity asLongFloat
+    ].
+    ^ PositiveInfinity
+
+    "
+     LongFloat infinity
+    "
+
+    "Created: / 20-06-2017 / 13:53:45 / cg"
+!
+
+negativeInfinity
+    "return a shortFloat which represents positive infinity"
+
+    NegativeInfinity isNil ifTrue:[
+        NegativeInfinity := Float negativeInfinity asLongFloat
+    ].
+    ^ NegativeInfinity
+
+    "
+     LongFloat negativeInfinity
+    "
+
+    "Created: / 20-06-2017 / 13:54:19 / cg"
+!
+
 pi
     "return the constant pi as LongFloat"