0

I tried to multiply a float with an int number like this:

>>> 1.2233 * 100
122.33000000000001

1.2233 * 100 = 122.33 but the result in Python is 122.33000000000001.

phqb
  • 351
  • 3
  • 14
  • Have a look at this http://stackoverflow.com/questions/11950819/python-math-is-wrong – Ashoka Lella Jul 03 '14 at 11:23
  • Technically, the answer to your question is that it was more likely a priori to happen that `1.2233 * 100` would not be the floating-point number nearest to 122.33 (i.e. the floating-point number that would get printed as `122.33`) because 122.33 is just below the power of two 128 and 1.2233 is just above the power of two 1. If you are interested as that level, see http://stackoverflow.com/a/18036308/139746 – Pascal Cuoq Jul 05 '14 at 23:07

0 Answers0