python带有大数的除法自动天花板

时间:2019-07-15 07:48:24

标签: python division

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(111111111111111111/10)
1.1111111111111112e+16
>>> print(int(111111111111111111/10))
11111111111111112
>>>

参考上面的代码片段,有人可以帮我理解为什么111111111111111111/10返回11111111111111112而不是11111111111111111的原因吗?

1 个答案:

答案 0 :(得分:3)

使用floor division

>>> 111111111111111111//10
11111111111111111
>>>