[Numpy-discussion] floating point arithmetic issue
Fri Jul 30 05:45:47 CDT 2010
I ran into a difficulty with floating point arithmetic in python. Namely
>>> 0.001 + 1 - 1
And, as a consequence, in python:
>>> 0.001 + 1 - 1 == 0.001
In more details, my problem is that I have a fonction which needs to
compute (a + b - c) % a. And for b == c, you would expect the result to
be 0 whatever the value of a. But it isn't...
>>> (0.001 + 1 - 1) % 0.001
Is there any way to solve this?
More information about the NumPy-Discussion