#FEATURE by exept
authorClaus Gittinger <cg@exept.de>
Sun, 01 Dec 2019 05:26:20 +0100
changeset 5328 f1d46108f6f8
parent 5327 9cecf32b06e2
child 5329 445e4a194cd1
#FEATURE by exept class: QuadFloat added: #asIEEEFloat class: QuadFloat class comment/format in: #coerce: #numBitsInMantissa
QuadFloat.st
--- a/QuadFloat.st	Sun Dec 01 05:26:12 2019 +0100
+++ b/QuadFloat.st	Sun Dec 01 05:26:20 2019 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "{ Package: 'stx:libbasic2' }"
 
 "{ NameSpace: Smalltalk }"
@@ -293,7 +291,7 @@
 !QuadFloat class methodsFor:'coercing & converting'!
 
 coerce:aNumber
-    "convert the argument aNumber into an instance of the receiver's class and return it."
+    "convert the argument aNumber into an instance of the receiver (class) and return it."
 
     ^ aNumber asQuadFloat.
 
@@ -521,9 +519,8 @@
     "answer the number of bits in the mantissa
      the hidden bit is not counted here:
 
-     This is an 128bit quadfloat,
-	   where 112 bits are available in the mantissa:
-	seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...
+     This is an 128bit quadfloat, where 112 bits are available in the mantissa:
+        seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...
     "
 
     ^ 112
@@ -1033,6 +1030,20 @@
     "
 !
 
+asIEEEFloat
+    "return an IEEE soft float with same value as receiver"
+
+    ^ IEEEFloat fromFloat:self
+
+    "
+     123 asFloat asIEEEFloat
+     0 asShortFloat asIEEEFloat
+     0 asLongFloat asIEEEFloat
+     0 asQuadFloat asIEEEFloat
+     0.0 asIEEEFloat
+    "
+!
+
 asQuadFloat
     ^ self