[squeak-dev] ScaledDecimal newFromNumber: 0.0 scale: 0 can't print
nicolas.cellier.aka.nice at gmail.com
Wed Sep 7 16:46:02 UTC 2011
OK, I had a chance to open an image and I see I'm responsible for this problem.
Levente changed the printing method, I recognized an already existing
Fraction>>printTruncatedOn:showingDecimalPlaces: and decided to use
it. But this message is not Integer friendly indeed.
Otherwise, there is no problem if the fraction ivar is an Integer, it
alerady was before, and can continue to be, as long as Integer
instances are polymorphic to Fraction (what they mostly are).
I gonna correct the mess this evening, thanks for reporting!
2011/9/7 Frank Shearar <frank.shearar at gmail.com>:
> 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)
> denominator: 1
>> 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