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) frank |
Isn't it also the case with (ScaledDecimal newFromNumber: 1.0 scale: 0) ?
2011/9/7 Frank Shearar <[hidden email]>: > 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) > > frank > > |
On 7 September 2011 12:32, Nicolas Cellier
<[hidden email]> 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 frank > 2011/9/7 Frank Shearar <[hidden email]>: >> 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) >> >> frank >> >> > > |
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! Nicolas 2011/9/7 Frank Shearar <[hidden email]>: > On 7 September 2011 12:32, Nicolas Cellier > <[hidden email]> 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 > > frank > >> 2011/9/7 Frank Shearar <[hidden email]>: >>> 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) >>> >>> frank >>> >>> >> >> > > |
And I just checked, and:
1) the senders of isFraction would work equally well if Integer>>isFraction did answer true. This is because they only expect the fraction to answer to #numerator and #denominator, and Integer does that quite well 2) this would fast up mixed Integer/Fraction arithmetic. 3) the senders of asFraction that really expect a Fraction are * Fraction>>adaptToInteger: rcvr andSend: selector * Integer>>adaptToFraction: rcvr andSend: selector But the later would be useless if Integer>>isFraction did answer true. 4) the other senders of #asFraction are in ScaledDecimal and don't care whether the Fraction really is a Fraction or an Integer So it might be time to enforce this peculiarity: Integer>>isFraction "Answer true because every Integer is polymorphic with a Fraction." Integer>>asFraction "See Integer>>#isFraction." ^self Nicolas 2011/9/7 Nicolas Cellier <[hidden email]>: > 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! > > Nicolas > > > 2011/9/7 Frank Shearar <[hidden email]>: >> On 7 September 2011 12:32, Nicolas Cellier >> <[hidden email]> 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 >> >> frank >> >>> 2011/9/7 Frank Shearar <[hidden email]>: >>>> 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) >>>> >>>> frank >>>> >>>> >>> >>> >> >> > |
Oops, it was in my image where Integer canUnderstand: #denominator,
does not seem the case in a base image ? Nicolas 2011/9/7 Nicolas Cellier <[hidden email]>: > And I just checked, and: > > 1) the senders of isFraction would work equally well if > Integer>>isFraction did answer true. > This is because they only expect the fraction to answer to > #numerator and #denominator, and Integer does that quite well > 2) this would fast up mixed Integer/Fraction arithmetic. > > 3) the senders of asFraction that really expect a Fraction are > * Fraction>>adaptToInteger: rcvr andSend: selector > * Integer>>adaptToFraction: rcvr andSend: selector > But the later would be useless if Integer>>isFraction did answer true. > 4) the other senders of #asFraction are in ScaledDecimal and don't > care whether the Fraction really is a Fraction or an Integer > > So it might be time to enforce this peculiarity: > Integer>>isFraction > "Answer true because every Integer is polymorphic with a Fraction." > Integer>>asFraction > "See Integer>>#isFraction." > ^self > > Nicolas > > 2011/9/7 Nicolas Cellier <[hidden email]>: >> 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! >> >> Nicolas >> >> >> 2011/9/7 Frank Shearar <[hidden email]>: >>> On 7 September 2011 12:32, Nicolas Cellier >>> <[hidden email]> 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 >>> >>> frank >>> >>>> 2011/9/7 Frank Shearar <[hidden email]>: >>>>> 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) >>>>> >>>>> frank >>>>> >>>>> >>>> >>>> >>> >>> >> > |
On 7 September 2011 18:24, Nicolas Cellier
<[hidden email]> wrote: > Oops, it was in my image where Integer canUnderstand: #denominator, > does not seem the case in a base image ? I can confirm that Integer does not understand #denominator in trunk. It wouldn't be crazy to just have Integer denominator [ ^ 1. ] and, if necessary, Integer numerator [ ^ self ] frank > Nicolas > > 2011/9/7 Nicolas Cellier <[hidden email]>: >> And I just checked, and: >> >> 1) the senders of isFraction would work equally well if >> Integer>>isFraction did answer true. >> This is because they only expect the fraction to answer to >> #numerator and #denominator, and Integer does that quite well >> 2) this would fast up mixed Integer/Fraction arithmetic. >> >> 3) the senders of asFraction that really expect a Fraction are >> * Fraction>>adaptToInteger: rcvr andSend: selector >> * Integer>>adaptToFraction: rcvr andSend: selector >> But the later would be useless if Integer>>isFraction did answer true. >> 4) the other senders of #asFraction are in ScaledDecimal and don't >> care whether the Fraction really is a Fraction or an Integer >> >> So it might be time to enforce this peculiarity: >> Integer>>isFraction >> "Answer true because every Integer is polymorphic with a Fraction." >> Integer>>asFraction >> "See Integer>>#isFraction." >> ^self >> >> Nicolas >> >> 2011/9/7 Nicolas Cellier <[hidden email]>: >>> 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! >>> >>> Nicolas >>> >>> >>> 2011/9/7 Frank Shearar <[hidden email]>: >>>> On 7 September 2011 12:32, Nicolas Cellier >>>> <[hidden email]> 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 >>>> >>>> frank >>>> >>>>> 2011/9/7 Frank Shearar <[hidden email]>: >>>>>> 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) >>>>>> >>>>>> frank >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >> > > |
2011/9/7 Frank Shearar <[hidden email]>:
> On 7 September 2011 18:24, Nicolas Cellier > <[hidden email]> wrote: >> Oops, it was in my image where Integer canUnderstand: #denominator, >> does not seem the case in a base image ? > > I can confirm that Integer does not understand #denominator in trunk. > It wouldn't be crazy to just have > > Integer denominator [ > ^ 1. > ] > > and, if necessary, > > Integer numerator [ > ^ self > ] > > frank > Absolutely, VW does, gst does, http://www.gnu.org/software/smalltalk/manual-base/html_node/Integer_002daccessing.html#Integer_002daccessing, I don't know why I was so sure Squeak did too. >> Nicolas >> >> 2011/9/7 Nicolas Cellier <[hidden email]>: >>> And I just checked, and: >>> >>> 1) the senders of isFraction would work equally well if >>> Integer>>isFraction did answer true. >>> This is because they only expect the fraction to answer to >>> #numerator and #denominator, and Integer does that quite well >>> 2) this would fast up mixed Integer/Fraction arithmetic. >>> >>> 3) the senders of asFraction that really expect a Fraction are >>> * Fraction>>adaptToInteger: rcvr andSend: selector >>> * Integer>>adaptToFraction: rcvr andSend: selector >>> But the later would be useless if Integer>>isFraction did answer true. >>> 4) the other senders of #asFraction are in ScaledDecimal and don't >>> care whether the Fraction really is a Fraction or an Integer >>> >>> So it might be time to enforce this peculiarity: >>> Integer>>isFraction >>> "Answer true because every Integer is polymorphic with a Fraction." >>> Integer>>asFraction >>> "See Integer>>#isFraction." >>> ^self >>> >>> Nicolas >>> >>> 2011/9/7 Nicolas Cellier <[hidden email]>: >>>> 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! >>>> >>>> Nicolas >>>> >>>> >>>> 2011/9/7 Frank Shearar <[hidden email]>: >>>>> On 7 September 2011 12:32, Nicolas Cellier >>>>> <[hidden email]> 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 >>>>> >>>>> frank >>>>> >>>>>> 2011/9/7 Frank Shearar <[hidden email]>: >>>>>>> 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) >>>>>>> >>>>>>> frank >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>> >> >> > > |
Free forum by Nabble | Edit this page |