[squeak-dev] The Trunk: Kernel-nice.562.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Mar 29 21:05:09 UTC 2011
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.562.mcz
==================== Summary ====================
Name: Kernel-nice.562
Author: nice
Time: 29 March 2011, 11:04:41.473 pm
UUID: 3fe28801-7a81-7848-b0af-3d246cf09488
Ancestors: Kernel-nice.561
Restore old behaviour:
-0.001 printShowingDecimalPlaces: 2
gives:
'0.00'
rather than
'-0.00'
What do you prefer ?
=============== Diff against Kernel-nice.561 ===============
Item was changed:
----- Method: Fraction>>printOn:showingDecimalPlaces: (in category 'printing') -----
printOn: aStream showingDecimalPlaces: placesDesired
"Same as super, but provides a faster implementation by inlining some Fraction protocol thus avoiding intermediate Fraction creation."
| roundedFractionPart integerPart scaling |
placesDesired <= 0
ifTrue: [self rounded printOn: aStream]
ifFalse:
[scaling := 10 raisedToInteger: placesDesired.
integerPart := numerator abs quo: denominator.
roundedFractionPart := (numerator abs - (integerPart * denominator)) * scaling * 2 + denominator quo: denominator * 2.
roundedFractionPart = scaling
ifTrue:
[integerPart := integerPart + 1.
roundedFractionPart := 0].
+ "Don't print minus sign if result is rouded to zero"
+ (numerator negative and: [integerPart > 0 or: [roundedFractionPart > 0]]) ifTrue: [aStream nextPut: $-].
- numerator negative ifTrue: [aStream nextPut: $-].
integerPart printOn: aStream.
aStream nextPut: $..
roundedFractionPart printOn: aStream base: 10 length: placesDesired padded: true].!
More information about the Squeak-dev
mailing list
|