bug in modulus?
jantod at gmail.com
jantod at gmail.com
Sun Apr 23 11:58:38 EDT 2006
I think there might be something wrong with the implementation of
modulus.
Negative float values close to 0.0 break the identity "0 <= abs(a % b)
< abs(b)".
print 0.0 % 2.0 # => 0.0
print -1e-010 % 2.0 # =>1.9999999999
which is correct, but:
print -1e-050 % 2.0 # => 2.0
print -1e-050 % 2.0 < 2.0 # => False
This means I can't use modulus to "wrap around" before it reaches a
certain value. I'm using Python 2.4.2 on WindowsXP.
Thanks
Janto
More information about the Python-list
mailing list