This has nothing to do with precision of the arithmetics, it's only about output formatting:
% python
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print(2.2*55)
121.0
>>> print("%.20f" % (2.2*55))
121.00000000000001421085
% python3
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(2.2*55)
121.00000000000001
>>> print("%.20f" % (2.2*55))
121.00000000000001421085
the culprit is that 2.2 is not representable as a float. It is rounded to something close:
>>> print("%.20f" % (2.2))
2.20000000000000017764
If you don't want to see that many zeros followed by digit in the output, limit the output precision. If you want to have more decimal friendly arithmetic, you can use the Decimal
type.
See also this question: Python format default rounding when formatting float number