|
is 0.1 a Float or a ScaledDecimal ?: msg#00142lang.smalltalk.squeak.beginners
I have another interrogation. Please take it as a student/newbie whatever question. I think 0.1 should be considered as a ScaledDecimal so that we could write 0.1 asFraction and have 1/10... To achieve that, there is a method that the Parser call... Number class >> readFrom: aStream which call: Number class>>readRemainderOf: integerPart from: aStream base: base withSign: sign which call: Number class>>readScaledDecimal: integerPart fractionPart: fractionPart digits: fractionDigits base: base sign: sign from: aStream ... What's interesting as a newbie perspective is the way I found these interesting methods... - only debug "0.1 asFraction" doesn't help, because it's hapening at "parse time"... I could have searched for selector containing "scaleddecimal" with cmd+shift+w but I did not... - Instead, as I knew it was related to Parser or Scanner, I looked in these class, then find Scanner scan: aStream. So I did: Scanner new scan: ('0.0123' readStream). "and the debut it" What these methods say is basically: 0.1234 evaluate as a Float and 0.1234s4 evaluated as a scaled decimal (because of s). IMvHO, I think at least decimal up to say scale 4 should be a scaled decimal... What do you think ? I have no idea of performance concerns... so I'll be pleased to have any knowledgeable insights :) Thanks a lot Cédrick _______________________________________________ Beginners mailing list Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx http://lists.squeakfoundation.org/mailman/listinfo/beginners
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: More Morphic Fun, Edgar J. De Cleene |
|---|---|
| Next by Date: | Re: is 0.1 a Float or a ScaledDecimal ?, Bert Freudenberg |
| Previous by Thread: | More Morphic Fun, Jeffrey Straszheim |
| Next by Thread: | Re: is 0.1 a Float or a ScaledDecimal ?, Bert Freudenberg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |