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: Division Error
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: azimuth84, effbot
Priority: normal Keywords:

Created on 2005-11-13 14:41 by azimuth84, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg26873 - (view) Author: Azimuth (azimuth84) Date: 2005-11-13 14:41
The division operation "7.0/5" yields 1.399999 instead
of 1.4
msg26874 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2005-11-13 15:52
Logged In: YES 
user_id=38376

This is not a bug.

Binary floating point cannot represent decimal fractions exactly,
so some rounding always occurs (even in Python 1.5.2).

What changed is that Python 2.0 shows more precision than before
in certain circumstances (repr() and the interactive prompt). 

You can use str() or print to get the old, rounded output: 

>>> print 0.1+0.1
0.2
>>>

Follow the link for more information:

http://www.python.org/doc/2.2.1/tut/node14.html
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42589
2005-11-13 14:41:02azimuth84create