>>> print('result:%9.2f' % 1111.225)
result: 1111.22
>>> print('result:%9.2f' % 11111.225)
result: 11111.23
>>> print('result:%9.2f' % 111.225)
result: 111.22
>>> print('result:%9.2f' % 11.225)
result: 11.22
>>> print('result:%9.2f' % 1.225)
result: 1.23
In the above example, you can see that 111.225
and 11.225
are rounded downwards, while the others are rounded upwards. As they all end on .225
, one would expect them all to be rounded upwards to .23
. Why does the rounding of the numbers differ?