[Numpy-discussion] Precision in Python
Nadav Horesh
nadavh at visionsense.com
Wed Dec 6 01:52:35 EST 2006
-----Original Message-----
From: numpy-discussion-bounces at scipy.org [mailto:numpy-discussion-bounces at scipy.org] On Behalf Of Elton Mendes
Sent: Monday, November 27, 2006 13:57
To: numpy-discussion at scipy.org
Subject: [Numpy-discussion] Precision in Python
Hi.
I'm having a precision problem in python
Example:
>>> a = 5.14343434
>>> b = round(a,1)
>>> b
5.0999999999999996
>>>
It´s possible to round the number exactly to 5.1
NO.
5.1 can not be represented exactly as a machine native float. The only way I know to represent this value exactly is to use the decimal module. Usually you do not want to do this.
Nadav.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20061206/aa803ebb/attachment.html>
More information about the NumPy-Discussion
mailing list