class: ShortFloat
authorClaus Gittinger <cg@exept.de>
Wed, 25 Mar 2015 16:41:55 +0100
changeset 18126 09b566fe7597
parent 18125 447519ca12b9
child 18127 0fca3e1acc6e
class: ShortFloat added: #fromNumber:
ShortFloat.st
--- a/ShortFloat.st	Wed Mar 25 16:41:40 2015 +0100
+++ b/ShortFloat.st	Wed Mar 25 16:41:55 2015 +0100
@@ -479,31 +479,12 @@
     ^ Float e asShortFloat
 !
 
-emax
-    "Answer the maximum exponent for this representation."
-
-    ^127
-!
-
-emin
-    "Answer the minimum exponent for this representation."
-
-    ^-126
-!
-
 pi
     "return the constant pi as ShortFloat"
 
     ^ Float pi asShortFloat
 !
 
-powersOfTwo
-    "/ sigh: cannot have PoersOfTwo as class nstvar (yet)
-    PowersOfTwo notNil ifTrue: [^PowersOfTwo].
-    PowersOfTwo := self newPowersOfTwo.
-    ^PowersOfTwo
-!
-
 unity
     "return the neutral element for multiplication (1.0) as ShortFloat"
 
@@ -1205,42 +1186,6 @@
      LimitedPrecisonReal and its subclasses use #printString instead of
      #printOn: as basic print mechanism."
 
-    ^ self printStringWithFormat:DefaultPrintFormat
-
-    "
-        1.234 asShortFloat printString.
-        1.0 asShortFloat printString.
-        1e10 asShortFloat printString.
-        1.2e3 asShortFloat printString.
-        1.2e30 asShortFloat printString.
-        (1.0 uncheckedDivide:0) asShortFloat printString.
-        (0.0 uncheckedDivide:0) asShortFloat printString.
-        self pi printString.
-
-        self pi printString.
-        DefaultPrintFormat := '.3'.
-        self pi printString.
-        DefaultPrintFormat := '.7'.
-
-        DecimalPointCharacterForPrinting := $,.
-        1.234 asShortFloat printString.
-        1.0 asShortFloat printString.
-        1e10 asShortFloat printString.
-        1.2e3 asShortFloat printString.
-        1.2e30 asShortFloat printString.
-        (1.0 uncheckedDivide:0) asShortFloat printString.
-        (0.0 uncheckedDivide:0) asShortFloat printString.
-        DecimalPointCharacterForPrinting := $.
-    "
-!
-
-printStringWithFormat:format
-    "return a printed representation of the receiver;
-     fmt must be of the form: .nn, where nn is the number of digits.
-     To print 6 valid digits, use printStringWithFormat:'.6'
-     For Floats, the default used in printString, is 15 (because its a double);
-     for ShortFloats, it is 6 (because it is a float)"
-
 %{  /* NOCONTEXT */
 
     char buffer[64];
@@ -1250,11 +1195,11 @@
     char *fmt;
     char fmtBuffer[20];
 
-    if (__isStringLike(format)) {
-        fmt = (char *) __stringVal(format);
+    if (__isStringLike(@global(DefaultPrintFormat))) {
+        fmt = (char *) __stringVal(@global(DefaultPrintFormat));
     } else {
         /*
-         * in case we get called with garbage...
+         * in case we get called before #initialize ...
          */
         fmt = ".7";
     }
@@ -1308,9 +1253,8 @@
     ^ self asFloat printString
 
     "
-        1.234 asShortFloat printString. 
-        ShortFloat pi printString.  
-        1.0 asShortFloat printString.   
+        1.234 asShortFloat printString.
+        1.0 asShortFloat printString.
         1e10 asShortFloat printString.
         1.2e3 asShortFloat printString.
         1.2e30 asShortFloat printString.
@@ -2098,11 +2042,11 @@
 !ShortFloat class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.140 2015-03-25 19:18:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.137 2015-03-25 15:41:55 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.140 2015-03-25 19:18:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.137 2015-03-25 15:41:55 cg Exp $'
 ! !