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: Math Division Problem?
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: grasp81, sjoerd
Priority: normal Keywords:

Created on 2004-03-19 13:20 by grasp81, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg20270 - (view) Author: GrASP (grasp81) Date: 2004-03-19 13:20
Using
Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC 
v.1200 32 bit (Intel)] on win32

A mere real division resulted in this:
>>> 7.0/3
2.3333333333333335

Mind the trailing '5'. Did I miss my University classes too 
much? ;)

Amazingly,
>>> 4.0/3
1.3333333333333333
- works OK.
msg20271 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2004-03-19 14:23
Logged In: YES 
user_id=43607

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:03adminsetgithub: 40052
2004-03-19 13:20:25grasp81create