--- a/PrintfScanf.st Sun Jun 18 22:43:12 2017 +0200
+++ b/PrintfScanf.st Sun Jun 18 22:46:40 2017 +0200
@@ -271,9 +271,9 @@
"x is myself normalized to (1.0, 10.0), exp is my exponent"
exp := absVal < 1.0
ifTrue:[
- (10.0 / absVal) log floor negated ]
+ (10.0 / absVal) log floor asInteger negated ]
ifFalse:[
- absVal log floor].
+ absVal log floor asInteger].
x := absVal / (10.0 raisedTo:exp).
fuzz := 10.0 raisedTo:1 - digits.
x := 0.5 * fuzz + x.
@@ -293,7 +293,7 @@
].
[ x >= fuzz ] whileTrue:[
"use fuzz to track significance"
- i := x truncated.
+ i := x truncated asInteger.
aStream nextPut:(48 + i) asCharacter.
x := (x - i) * 10.0.
fuzz := fuzz * 10.0.
@@ -310,7 +310,7 @@
]
]
- "Modified (comment): / 16-06-2017 / 10:40:28 / cg"
+ "Modified: / 17-06-2017 / 03:41:44 / cg"
!
absPrintFloat:aFloat on:aStream digits:digits
@@ -426,7 +426,8 @@
ljust := plus := pound := false.
width := 0.
- precision := SmallInteger maxVal.
+ "/ precision := SmallInteger maxVal.
+ precision := nil.
pad := $ .
char := inStream peek.
@@ -484,11 +485,12 @@
].
('feg' includes: char) ifTrue:[
- arg := argStream next asFloat.
+ arg := argStream next.
arg isLimitedPrecisionReal ifTrue:[
- precision := precision min: (arg defaultPrintPrecision).
- ] ifFalse:[
- precision := precision min:(Float defaultPrintPrecision).
+ precision := precision ? (arg class defaultPrintPrecision).
+ ] ifFalse:[
+ arg := arg asFloat.
+ precision := precision ? (Float defaultPrintPrecision).
].
argString := WriteStream on:''.
char == $g ifTrue: [
@@ -559,13 +561,13 @@
]
].
- precision := precision min: arg size.
+ precision := precision ? arg size.
ljust ifTrue: [outStream nextPutAll: (arg copyFrom: 1 to: precision)].
width - precision timesRepeat: [outStream nextPut: pad].
ljust ifFalse: [outStream nextPutAll: (arg copyFrom: 1 to: precision)].
^ inStream next
- "Modified: / 17-06-2017 / 03:00:07 / cg"
+ "Modified: / 17-06-2017 / 03:38:35 / cg"
!
printf:aString arguments:args