Is there precision in this number that Python isn't showing me?
<p>I've run into something odd, here, and I'm at a loss -- I have a feeling this has something to do with floating precision, but I'm surprised Python would not display the approximation error, if so.</p>

<p>I'm working on <a href="http://projecteuler.net/index.php?section=problems&amp;id=62" rel="nofollow">Project Euler problem 62</a>.  As a simple test (I've since solved using a different approach), I had a <code>is_cube</code> which I intended to check if a number cubes perfectly. So, to try the sample given, I did this:</p>

<pre><code>def is_cube(i):
    c = i ** (1./3)
    print "c is", c
</code></pre>

<p>When I ran this with i = 41063625, the expected output was:</p>

<pre><code>c is 345.0
</code></pre>

<p>Here's where the unexpected happened:</p>

<pre><code>def is_cube(i):
    c = i ** (1./3)
    print "c is", int(c)
</code></pre>

<p>Suddenly, I had this:</p>

<pre><code>c is 344
</code></pre>

<p>The value <code>c</code> does not compare against my <code>345.0</code> literal, either -- <code>c &lt; 345.0</code> is True.</p>

<p>Is there precision in this number that Python is not showing me?  I seem to recall reading about a change to make floats appear more sane when printed; is this it?  What is different about these two cases?</p>

<pre><code>&gt;&gt;&gt; def is_cube(i):
...     c = i ** (1./3)
...     print "c is", c
... 
&gt;&gt;&gt; is_cube(41063625)
c is 345.0
&gt;&gt;&gt; 41063625 ** (1./3)
344.99999999999989
</code></pre>

<p><strong>Edit:</strong> Still had the window open and did this:</p>

<pre><code>&gt;&gt;&gt; print _
345.0
</code></pre>

<p>Now I'm starting to think I should have known all along that <code>print</code> was to blame.</p>
