Floating point implementations vary among programming languages. On the same machine and OS (win10), the equation 0.3 - 0.1 equals varying numbers depending on the calculator;
Powershell says 0.2,
calc.exe app and libreoffice calc agree with 0.2,
BC running in CYGWin also 0.2,
Python 2 and 3 answer 0.19999999999999998,
JS in Vivaldi and firefox also answer 0.19999999999999998,
> if you get 0.2, the code is using rational numbers or a custom implementation
IIRC, there are languages that use IEEE double precision but the way they handle default display presents this as 0.2 (basically, they use a display algorithm that displays the shortest decimal expression that has the same double precision representation.)
0.2 could just be base 10 / decimal floating point rather than the base 2 single/double i think, It’s all ieee754 it’s just the base10 stuff came later
As far as I know, BC doesn't do floating point arithmetic. It does fixed point arithmetic, built on top of arbitrary-precision integer arithmetic. Which is why it won't give you one of those funny floating point answers. It's what a human would do on a piece of paper.
Floating point implementations can vary not only between languages, but also between different CPUs, if the language relies on the hardware implementation (which is the smart thing to do in most cases).
As a side note: Python's implementation of FP isn't standard-compliant. E.g. when you divide by 5.0 by 0.0, the standard says you should get a +inf. In Python you get an exception.
Actually, according to the standard, you should get either +inf or an exception.
Both behaviors are valid.
Nevertheless, according to the standard, the user should be able to choose between getting +inf and getting an exception.
If in Python there is no way to mask the divide by zero exception, then that is not standard-compliant.
Powershell says 0.2,
calc.exe app and libreoffice calc agree with 0.2,
BC running in CYGWin also 0.2,
Python 2 and 3 answer 0.19999999999999998,
JS in Vivaldi and firefox also answer 0.19999999999999998,
But Portacle (Common Lisp) returns 0.20000002