Float.st
changeset 3894 cf409b39bc5c
parent 3889 3466554b639f
child 3896 ff8ef5f6f3e9
--- a/Float.st	Tue Oct 27 13:34:47 1998 +0100
+++ b/Float.st	Wed Oct 28 17:04:15 1998 +0100
@@ -697,15 +697,15 @@
 
     double frexp();
     double frac;
-    INT pwr;
+    INT exp;
 
     errno = 0;
-    frac = frexp(__floatVal(self), &pwr);
+    frac = frexp(__floatVal(self), &exp);
     if (errno == 0) {
-        if (pwr == 0) {
+        if (exp == 0) {
             RETURN (__MKSMALLINT(0));
         }
-        RETURN (__MKSMALLINT(pwr-1));
+        RETURN (__MKSMALLINT(exp-1));
     }
 %}.
     ^ self primitiveFailed
@@ -723,9 +723,9 @@
 !
 
 fractionalPart
-    "extract a normalized floats mantissa.
-     This assumes that the mantissa is normalized to
-     0.5 .. 1.0 and the floats value is mantissa * 2^exp"
+    "extract the after-decimal fraction part.
+     the floats value is 
+        float truncated + float fractionalPart"
 
 %{  /* NOCONTEXT */
 
@@ -750,6 +750,12 @@
      3.14159 fractionalPart   
      12345673.14159 fractionalPart   
      123456731231231231.14159 fractionalPart   
+
+     3.14159 fractionalPart + 3.14159 truncated  
+
+     12345673.14159 fractionalPart + 12345673.14159 truncated  
+
+     123456731231231231.14159 fractionalPart + 123456731231231231.14159 truncated  
     "
 !
 
@@ -757,6 +763,40 @@
     "return the generality value - see ArithmeticValue>>retry:coercing:"
 
     ^ 80
+!
+
+mantissa
+    "extract a normalized floats mantissa.
+     The returned value depends on the float-representation of
+     the underlying machine and is therefore highly unportable.
+     This is not for general use.
+     This assumes that the mantissa is normalized to
+     0.5 .. 1.0 and the floats value is mantissa * 2^exp"
+
+%{  /* NOCONTEXT */
+
+    double frexp();
+    double frac;
+    INT exp;
+
+    errno = 0;
+    frac = frexp(__floatVal(self), &exp);
+    if (errno == 0) {
+        RETURN (__MKFLOAT(frac));
+    }
+%}.
+    ^ self primitiveFailed
+
+    "
+     1.0 exponent    
+     1.0 mantissa    
+
+     0.25 exponent   
+     0.25 mantissa   
+
+     0.00000011111 exponent   
+     0.00000011111 mantissa   
+    "
 ! !
 
 !Float methodsFor:'comparing'!
@@ -1790,6 +1830,6 @@
 !Float class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.86 1998-10-22 18:13:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.87 1998-10-28 16:04:15 cg Exp $'
 ! !
 Float initialize!