[Python-bugs-list] [Bug #126586] Floating point is broken in Python 2.0

noreply@sourceforge.net noreply@sourceforge.net
Thu, 21 Dec 2000 08:15:07 -0800


Bug #126586, was updated on 2000-Dec-21 04:03
Here is a current snapshot of the bug.

Project: Python
Category: IDLE
Status: Closed
Resolution: Invalid
Bug Group: Not a Bug
Priority: 5
Submitted by: nobody
Assigned to : nobody
Summary: Floating point is broken in Python 2.0

Details: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.6 -- press F1 for help
>>> p=0.6
>>> p
0.59999999999999998
>>> 

Follow-Ups:

Date: 2000-Dec-21 08:15
By: tim_one

Comment:
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 a detailed example:

http://www.python.org/cgi-bin/moinmoin/RepresentationError

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=126586&group_id=5470