<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div>Yes sure, that's a possibility.<br></div><div>But that means changing well established Smalltalk syntax, and thus modify a huge library of source code...<br></div><div><br></div><div>We currently have ScaledDecimal with 3.41s or 3.42s2 syntax.</div><div>The problem with ScaledDecimal is that their printing is ambiguous: two different ScaledDecimal may print the same.</div><br>    {1.0s2 / 3.0s2. 0.33s2} collect: #printString.<br>    {1.0s2 / 3.0s2. 0.33s2} collect: #reciprocal.</div><div dir="ltr"><br><div>They just truncate in Squeak (and maybe round in Pharo, not even with banker rounding).</div><div>This is because they are just Fraction in disguise, and that's their second problem: repeated computations could lead to monstruous fractions.</div><div><br></div><div>That's why I'm interested in experiments: is their usage sustainable, or does it lead to explosion?</div><div>It's very easy to experiment: introduce a new NumberParser subclass and connect it to Smalltalk Parser (via Scanner>>#xDigit).</div><div>Then, carefully recompile some part of the system, and discover the vital source code where Float literals are required.<br></div><div><br></div><div>We could also introduce FixedPoint, a number that would round to a fixed number of fractional digits. And maybe DecimalFixedPoint and BinaryFixedPoint for the two principal usefull flavours.</div><div>The problem with FixedPoint is that we must decide in advance how many digits?</div><div>A FixedPoint vs FloatingPoint is trading a bit more precision vs lot less range, so it's maybe not that intersting for a general purpose library...</div><div><br></div><div>Or we could have a DecimalFloat, a Floating point in base 10. <a href="https://en.wikipedia.org/wiki/Decimal_floating_point">https://en.wikipedia.org/wiki/Decimal_floating_point</a><br></div><div>Maybe that's the practical universal Number that we are after?</div><div>Of course, like the other kinds above, it would be emulated...<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 7 avr. 2019 à 05:10, K K Subbu <<a href="mailto:kksubbu.ml@gmail.com" target="_blank">kksubbu.ml@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
Squeak compiler compiles numbers like "3.4" into SmallFloat types. But <br>
Squeak can also handle number pairs like Point and Fractions. Has anyone <br>
considered decimals into fractions, instead? Like how we treat fractions <br>
in real life? $0.02 is really 2/100th of a dollar. I wouldn't want it to <br>
float ;-).<br>
<br>
Squeak could compile fix points like "3.4" into fractions like "34/10" <br>
and compile into float only if an explicit exponent is given like in <br>
"3.4e0". This would help us maintain accuracy as long as possible in <br>
fraction arithmetic we use in daily life. e.g.<br>
<br>
3.41 - 3.40 0.010000000000000231<br>
vs<br>
((341/100) - (340/100)) asFloat 0.01<br>
<br>
Regards .. Subbu<br>
</blockquote></div>