While working with the division remainder operator % in python 2.7 I faced an unexpected behavior (at least for me) when using it with decimal denominators. Bellow an example:
>>> 0.1%0.1
0.0 # as expected
>>> 0.2%0.1
0.0 # as expected
>>> 0.3%0.1
0.09999999999999998 # what the hell?
>>> 0.4%0.1
0.0 # aw expected
>>> 0.5%0.1
0.09999999999999998 # what the hell?
Why the operations 0.3%0.1 and 0.5%0.1 return the result above instead of 0.0 as in the other cases and as I was expecting?
Thanks