np.cast in numpy results in incorrect result
<p>This use of np.cast: </p>

<pre><code>np.cast['f'](np.pi)
</code></pre>

<p>results in an incorrect value for pi:</p>

<pre><code>array(3.1415927410125732, dtype=float32)
</code></pre>

<p>why did this happen?</p>

<p>Real pi value up to a few digits more than <code>float32</code> precision (from <a href="http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html" rel="nofollow">here</a>)</p>

<pre><code>`3.14159265358979323846264338327950288...` 
</code></pre>

<p><code>float32</code> precision has an accuracy from 6 to 9 decimal places  (from <a href="https://en.wikipedia.org/wiki/Single-precision_floating-point_format" rel="nofollow">here</a>)</p>

<pre><code> 3.1 4 1 5 9 2 7 4 1  0125732 #  your value
 3.1 4 1 5 9 2 6 5 3  5897    # actual value
 --1 2 3 4 5 6 7 8 9   # (index of decimal place)
</code></pre>

<p>As you can see the deviation from the real value happens after the 7th decimal place. So that's the reason why it is not right after that</p>

python numpy