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.

classification
Title: Round funcion
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, gust1
Priority: normal Keywords:

Created on 2007-03-24 11:02 by gust1, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py gust1, 2007-03-24 11:02 Correction propose
Messages (2)
msg31646 - (view) Author: Gust1 (gust1) Date: 2007-03-24 11:02
I don't quite know if it is a bug, but when I do this in the interpreter (see blow) the third return is not what i wanted.

>>> round(5.5, 3)
5.5
>>> round(5.5555555555, 3)
5.556
>>> round(5.5555555555, 2)
5.5599999999999996

I created a function to solve this. It can be found attached to this report.

I'm sorry but I'm not English so I don't speak this language very good.
msg31647 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-24 11:37
This is invalid. See http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44771
2007-03-24 11:02:59gust1create