I am also a bit intrigued by this. Like you said: several other programming languages (I tried a couple of Common Lisp and Scheme implementations) do the same as Pharo, but handheld calculators, normal and scientific, do not.
I think that going for 1/10 fractions/precision is not going to help: you got a division by 113 in your formula [https://en.wikipedia.org/wiki/Handicap_(golf)], this will give smaller fractions. The problem is not the calculation (modern 64-bit floats as in Pharo are plenty accurate), it is how you handle results. You should just round it correctly and be done with it. Note that a roundTo: 0.00000000000001. (1e-14) still gives 4.5 it is only one step further that you hit the limit and get the ugly but correct result. I assume that most calculators always use a printing precision that is lower than their internal precision, hence they hide this reality. When computing with money, you would be inclined to put everything in cents (because you cannot divide them further). But once you start computing percentage discounts or taxes, you again get problems. At each of those steps you must make sure that no cents are lost. > On 16 Jun 2021, at 15:19, Esteban Maringolo <emaring...@gmail.com> wrote: > > On Wed, Jun 16, 2021 at 9:13 AM Konrad Hinsen > <konrad.hin...@fastmail.net> wrote: >> >> On 15/06/2021 16:05, Esteban Maringolo wrote: >>> And in this particular case, it might cause issues, since the "full >>> precision" (whatever that means) must be retained when using such a >>> number to derive another one. >> >> To me, "full precision" means "no precision is ever lost in arithmetic >> operations". If that's what you need, your choices are >> >> 1) Integers >> >> 2) Rational numbers (fractions) > >> Pharo has 1) and 2). > > Yeap, I'll switch to 2. > > What I'm not totally convinced of is whether to store numbers as > integers (knowing beforehand the decimal precision, and converting it > to fractions when read back) or if to store them as scaled decimals > (which internally hold a fraction). > > Thanks!