0

Run these two commands in Python:

print(int(822981260158260520/2))
print(int(822981260158260520//2))

The second one prints a correct answer but the first one does not. The difference is as big as 20. How did this happen? Is it a Python bug?

user3288177
  • 479
  • 1
  • 4
  • 9
  • 1
    See this for more detail: https://docs.python.org/3/tutorial/floatingpoint.html – ZaxR Jun 13 '18 at 03:23
  • 1
    The duplicate does not answer your question. The answer is that / is a float division while // is an int division that will only return the whole part (integer) of the result. – Olivier Melançon Jun 13 '18 at 04:23

0 Answers0