[Newbies] is 0.1 a Float or a ScaledDecimal ?
cdrick65 at gmail.com
Wed Feb 20 10:31:28 UTC 2008
I have another interrogation. Please take it as a student/newbie
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
Number class>>readRemainderOf: integerPart from: aStream base: base
Number class>>readScaledDecimal: integerPart fractionPart:
fractionPart digits: fractionDigits base: base sign: sign from:
What's interesting as a newbie perspective is the way I found these
- only debug "0.1 asFraction" doesn't help, because it's hapening at
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
More information about the Beginners