Comparing a float and an int in Python
<p>I am trying to see if the calculated distance between two points is smaller than a given radius like this:</p>

<pre><code>if distance(lat1, long1, lat2, long2) &lt; radius:
      print "Distance: %s Radius: %s" % (distance(lat1, long1, lat2, long2), radius)
</code></pre>

<p>Here <code>distance</code> would effectively return a <code>float</code> and <code>radius</code> is an <code>int</code>.</p>

<p>I do know that I should not compare floats directly and that I should compare with a threshold. Given that, is there a better way to check if a float is less than an int (or another float).</p>

<p><strong>Update</strong>
This comparison seems to be ok from all of the replies. But I did observe this:</p>

<pre><code>&gt;&gt;&gt; 1.2000000000000001 &gt; 1.2
True
&gt;&gt;&gt; 1.20000000000000001 &gt; 1.2
False
</code></pre>

<p>Isn't this a problem? I am using Python 2.6.7 on Mac</p>
