Hi all,
this is a rather loose collection of some observations and questions that came to my mind while exploring floats and scaled decimals. Comments and patches appreciated.
1. Exponential notation in radix floats
13r0.1e2 --> 13.0
14r0.1e2 --> 14.0
15r0.1e2 --> 0.12948148148148148
"How can I specify the exponent for bases where e is treated a digit? Should this be possible in literal syntax?"
2. Exponent letters
"Answer to myself re 1:"
15r0.1q2 --> 15.0
"Wow! Why is this supported in SqNumberParser>>#exponentLetters? I have seen this nowhere else. And just to uphold my question from above, think about this:"
26r0.1q2 --> 26.0
27r0.1q2 --> 0.0728039424884418
3. Limited precision in scaled decimals
SpaceTally new spaceForInstance: 0.10s2 depth: 2. --> 48
SpaceTally new spaceForInstance: 0.1010101010101010101010101010101010101010101010101010101010101010s2 depth: 2. --> 128
"If not here, when is precision lost at all? Should the number parser truncate this? How can I compact my existing scaled decimal instances based on their scale?"
4. Scale in radix notation
"Follow-up question for 3., so I could not really test this:"
2r0.10101s1 --> 0.6s1
2r0.10101s2 --> 0.65s2
"I would rather have expected 0.5s1 and 0.5s1 here. So, the current behavior seems to be that the scale always refers to the decimal representation of the number even though the literal is written in a different base? Does this actually make any sense or should we disallow this combination of radix and scale? Or can we translate the scale to between the numeral systems, i.e., (sourceBase ** sourceScale - 1 log: targetBase) ceiling?"
5. Printing scaled decimals in base
1s printStringBase: 2 --> error: SubclassResponsibility: My ScaledDecimal subclass should have overridden printOn:base:
"Seems to be missing yet..."
6. Beyond base 36
"This is clear:"
35 printStringBase: 36 --> 'Z'
36rZ --> 35
"But then..."
36 printStringBase: 37 --> '['
37r[ --> syntax error: a digit between 0 and [ expected ->[
"D'oh! And the error message does not really make it clearer. :) Should we disallow radix base 37 and larger? Or can we just make it so that 44r~^é evaluates to 77263?"
Best,
Christoph
---
Sent from Squeak Inbox Talk