[squeak-dev] ScaledDecimal newFromNumber: 0.0 scale: 0 can't print
frank.shearar at gmail.com
Wed Sep 7 12:02:16 UTC 2011
On 7 September 2011 12:32, Nicolas Cellier
<nicolas.cellier.aka.nice at gmail.com> wrote:
> Isn't it also the case with (ScaledDecimal newFromNumber: 1.0 scale: 0) ?
It's true for any integral-valued float. Somewhere near the bottom of
Float >> #asTrueFraction the line
result := signedFraction bitShift: zeroBitsCount negated
returns an Integer.
Presumably (and I'm really just guessing here), we could say
result := Fraction
numerator: (signedFraction bitShift: zeroBitsCount negated)
> 2011/9/7 Frank Shearar <frank.shearar at gmail.com>:
>> Evaluate the following:
>> 0s0 "=> 0s0"
>> ScaledDecimal newFromNumber: 0 scale: 0 "=> 0s0"
>> 0.0s0 "=> 0s0"
>> ScaledDecimal newFromNumber: 0.0 scale: 0 "=> MNU: SmallInteger
>> doesn't understand printTruncatedOn:showingDecimalPlaces:"
>> The MNU happens because in ScaledDecimal class >> #newFromNumber:scale: we say
>> "..." aNumber asFraction "..."
>> and when aNumber = 0.0, aNumber asFraction = 0, which is a
>> SmallInteger and not a Fraction.
>> (Recorded as http://bugs.squeak.org/view.php?id=7667)
More information about the Squeak-dev