This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steve21
Recipients steve21
Date 2009-06-07.07:44:02
SpamBayes Score 4.147659e-06
Marked as misclassified No
Message-id <1244360644.6.0.321389592966.issue6228@psf.upfronthosting.co.za>
In-reply-to
Content
I wish to round the float 697.04157958254996 to 10 decimal digits after
the decimal point.

$ python3.0
Python 3.0.1 (r301:69556, Jun  7 2009, 14:51:41)
[GCC 4.3.2 20081105 (Red Hat 4.3.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> 697.04157958254996
697.04157958254996      # python float can represent this number exactly

>>> 697.04157958250000  # this is the expected result
697.04157958250005      # this is the closest python float representation

>>> round(697.04157958254996, 10)
697.04157958259998      # error

round() gives a result that is closer to
697.0415795826
than the expected result of
697.0415795825
- it has not rounded to the closest 10th decimal digit after the decimal
point.

(python 2.6.2 has the same problem)
History
Date User Action Args
2009-06-07 07:44:04steve21setrecipients: + steve21
2009-06-07 07:44:04steve21setmessageid: <1244360644.6.0.321389592966.issue6228@psf.upfronthosting.co.za>
2009-06-07 07:44:03steve21linkissue6228 messages
2009-06-07 07:44:02steve21create