Thank you sir...........  thank you very much.............<br><br><br><br><br><br><div class="gmail_quote">On Wed, Apr 6, 2011 at 9:36 PM, Christopher Barker <span dir="ltr"><<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On 4/6/11 6:24 AM, Alan G Isaac wrote:<br>
> <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.round_.html" target="_blank">http://docs.scipy.org/doc/numpy/reference/generated/numpy.round_.html</a><br>
<br>
</div>simple enough, of course, but just to be clear:<br>
<br>
In [108]: np.round(1.23456789, 3)<br>
Out[108]: 1.2350000000000001<br>
<br>
so the number is rounded to the requested number of decimal places, but<br>
then stored in a binary floating point format, which may not be able to<br>
exactly represent that rounded number -- hence the "1" at the end. This<br>
is simply how floating point works.<br>
<br>
and that slight difference _probably_ doesn't matter, but it's worth<br>
being aware of, because is does make a difference occasionally.<br>
<br>
python has a decimal type that can work with exact decimal numbers --<br>
numpy doesn't support that, as there is no hardware support for it (at<br>
least on most platforms).<br>
<br>
If you want to display it differently, you can use the string formatters:<br>
<br>
In [110]: "%.3f"%np.round(1.23456789, 3)<br>
Out[110]: '1.235'<br>
<br>
HTH, Chris<br>
<br>
<br>
--<br>
Christopher Barker, Ph.D.<br>
Oceanographer<br>
<br>
Emergency Response Division<br>
NOAA/NOS/OR&R            (206) 526-6959   voice<br>
7600 Sand Point Way NE   (206) 526-6329   fax<br>
Seattle, WA  98115       (206) 526-6317   main reception<br>
<br>
<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a><br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>DILEEPKUMAR. R<br>J R F, IIT DELHI<br><div style="display: inline;"></div><br>