The numpy remainder function is returning results I don't understand when given floating point numbers. I am not sure if this is a bug or a failure on my part to understand the documentation. For example
np.remainder(0.5, 0.001)
Out[165]: 0.00099999999999998961
np.remainder(0.499, 0.001)
Out[161]: 0.00099999999999998875
which should both be zero given my understanding of the function. The documentation says the function is equivalent to x1 - floor(x1 / x2) * x2
, but checking this gives the answer I expect:
0.5 - np.floor(0.5/0.001)*0.001
Out[166]: 0.0
Also,
np.remainder(0.499*1000, 0.001*1000)
Out[160]: 0.0
Insight into why this might be the case given floating point arithmetic would be greatly appreciated.