class: PrintfScanf class
authorClaus Gittinger <cg@exept.de>
Tue, 20 Jun 2017 12:21:47 +0200
changeset 4429 7d3e464fb430
parent 4428 f44ab76503a6
child 4430 2abefbc21260
class: PrintfScanf class changed: #absDecimalPrintFloat:on:digits: #absScientificPrintFloat:on:digits: care for Nan and Inf when printing.
extensions.st
--- a/extensions.st	Tue Jun 20 12:21:10 2017 +0200
+++ b/extensions.st	Tue Jun 20 12:21:47 2017 +0200
@@ -653,44 +653,10 @@
      on <aStream> using <digits> significant digits, using decimal notation.
      This is a helper for printf."
 
-    |exp x fuzz i|
+    <resource: #obsolete>
+    PrintfScanf absDecimalPrintFloat:self on:aStream digits:digits.
 
-    "x is myself normalized to (1.0, 10.0), exp is my exponent"
-    exp := self abs < 1.0
-                ifTrue:[ (10.0 / self abs) log10 floor negated ]
-                ifFalse:[ self abs log10 floor ].
-    x := self abs / (10.0 raisedTo:exp).
-    fuzz := 10.0 raisedTo:1 - digits.
-     "round the last digit to be printed"
-    x := 0.5 * fuzz + x.
-    x >= 10.0 "check if rounding has unnormalized x" ifTrue:[
-        x := x / 10.0.
-        exp := exp + 1
-    ].
-    exp < 0 ifTrue:[
-        1 to:1 - exp do:[:j |
-            aStream nextPut:('0.000000000000' at:j)
-        ]
-    ].
-    [ x >= fuzz ] "use fuzz to track significance" whileTrue:[
-        i := x truncated.
-        aStream nextPut:(48 + i) asCharacter.
-        x := (x - i) * 10.0.
-        fuzz := fuzz * 10.0.
-        exp := exp - 1.
-        exp = -1 ifTrue:[
-            aStream nextPut:$.
-        ]
-    ].
-    [ exp >= -1 ] whileTrue:[
-        aStream nextPut:$0.
-        exp := exp - 1.
-        exp = -1 ifTrue:[
-            aStream nextPut:$.
-        ]
-    ]
-
-    "Modified: / 19-06-2017 / 14:53:47 / cg"
+    "Modified: / 20-06-2017 / 11:49:15 / cg"
 ! !
 
 !Float methodsFor:'private'!
@@ -700,9 +666,10 @@
      <digits> significant digits.
      This is a helper for printf."
 
+    <resource: #obsolete>
     PrintfScanf absPrintFloat:self on:aStream digits:digits
 
-    "Modified: / 19-06-2017 / 15:04:24 / cg"
+    "Modified: / 20-06-2017 / 11:49:11 / cg"
 ! !
 
 !Float methodsFor:'private'!
@@ -712,9 +679,11 @@
      digits, using scientific notation.
      This is a helper for printf."
 
+    <resource: #obsolete>
     PrintfScanf absScientificPrintFloat:self on:aStream digits:digits.
 
     "Modified: / 19-06-2017 / 14:59:56 / cg"
+    "Modified (format): / 20-06-2017 / 11:49:07 / cg"
 ! !
 
 !Float methodsFor:'coercing & converting'!