--

Floating point isn't processors' biggest strength. But you should note that this is also programming language dependent.

Take Raku for instance ( https://www.raku.org/ ): Where possible it stores numbers as fractions/rational numbers. So with that language 0.1+0.2==0.3. You can even explicitly set the number type to a rational number with astonishing precision no matter how big or small it is.

Fun fact: The programming language COBOL, invented in 1959, also have something called fixed precision floats that avoids the problems you mention here. (Being used in banking systems, IRS, etc., avoiding rounding errors is very important).

You can read more about that here: https://medium.com/the-technical-archaeologist/is-cobol-holding-you-hostage-with-math-5498c0eb428b

--

--

Jo Christian Oterhals
Jo Christian Oterhals

Written by Jo Christian Oterhals

Norwegian with many interests. Programming being one of them.

No responses yet