问题描述
我很好奇为什么下面的整数除法运算会返回错误的结果。
这是蟒蛇:
[ins] In [16]: import numpy as np
[ins] In [17]: np.floor(0.84 / 0.02)
Out[17]: 42.0
[ins] In [18]: 0.84 / 0.02
Out[18]: 42.0
[ins] In [19]: 0.84 // 0.02 # should return 42,but..
Out[19]: 41.0
这也发生在 R 中
(0.84 %/% 0.02) # returns 41
(0.84 / 0.02) # returns 42
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)