Code:
numbers = (0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19)
for i in numbers:
print i,"=> %.1f" % i
Output:
0.11 => 0.1
0.12 => 0.1
0.13 => 0.1
0.14 => 0.1
0.15 => 0.1
0.16 => 0.2
0.17 => 0.2
0.18 => 0.2
0.19 => 0.2
I expected either that it will simply truncate unwanted numbers or that it will round them, but I receive something indirect. It didn't truncate because we get 0.2 and it didn't round because for 0.15 returns 0.1 instead of the expected 0.2.
I don't see any sense in it. Can somebody tell me how does it REALLY works?
*I tried various cases and always for X.X...X5 i get X.XX instead of X.X...(X+1). From zero to five numbers are truncated, from six to nine they are rounded.