I wrote the following for creating a range with negative floating point steps:
def myRange(start, stop, step):
s = start
if step < 0:
while s > stop:
yield s
s += step
if step > 0:
while s < stop:
yield s
s += step
But the output of r = myRange(1,0,-0.1)
looks rather strange
>>> r = myRange(1,0,-0.1)
>>> for n in r: print n
...
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
1.38777878078e-16
where does this last number come from? And why is it not 0?