Team Pharo,
The printOn: method in ScaledDecimal returns a positive number string where the
number is >-1 and < 0. For example -0.55s2 returns a string '0.55s2'.
I have made my own correction.
This may help the one other person who is using ScaledDecimal as a proxy for
Currency but I have no idea what to do with this astounding discovery nor
whether it will help anyone nor indeed if it is very tidy code.
Thanks
Guy Bloomfield
The current method starts with the string for the integer part 0 and then the
absolute value of the fraction:
printOn: aStream
"Append an approximated representation of the receiver on aStream.
Use prescribed number of digits after decimal point (the scale) using a
rounding operation if not exact"
| fractionPart |
scale = 0
ifTrue: [self rounded printOn: aStream]
ifFalse: [self integerPart printOn: aStream.
aStream nextPut: $..
fractionPart := (self abs fractionPart * (10
raisedToInteger: scale)) rounded.
.....
My correction:
printOn: aStream
"Append an approximated representation of the receiver on aStream.
Use prescribed number of digits after decimal point (the scale) using a
rounding operation if not exact"
| fractionPart |
self < 0 ifTrue: [ aStream nextPut: $- ].
scale = 0
ifTrue: [self rounded printOn: aStream]
ifFalse: [self abs integerPart printOn: aStream.
aStream nextPut: $..
fractionPart := (self abs fractionPart * (10
raisedToInteger: scale)) rounded.
.....