Why is my range function printing untruncated floats?
<p>I made this range function so I could have something other than an integer step, and it works, but I am wondering why the floats are not truncated.</p>

<pre><code>def drange(start, step):
    values = []
    r = start
    while r &gt;= 0:
        values.append(r)
        r += step
    return values


print drange(2, -0.2)
</code></pre>

<p>Upon debugging I find that instead of this printing</p>

<pre><code>[2, 1.8, 1.6, 1.4, 1.2, 1.0, 0.8, 0.6, 0.4, 0.2, 0]
</code></pre>

<p>it instead prints</p>

<pre><code>[2, 1.8, 1.6, 1.4000000000000001, 1.2000000000000002, 1.0000000000000002, 0.8000
000000000003, 0.6000000000000003, 0.4000000000000003, 0.2000000000000003, 2.7755
575615628914e-16]
</code></pre>

<p>Lol, no wonder my module isn't working. Why does this happen and how might I fix it?</p>
