I am curious why the following integer division operation returns a wrong result.
Here's python:
[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 This happens in R as well
(0.84 %/% 0.02) # returns 41 (0.84 / 0.02) # returns 42 https://stackoverflow.com/questions/66717753/integer-division-in-python-and-r-returns-interesting-wrong-numbers March 20, 2021 at 10:41AM
没有评论:
发表评论