[Python-bugs-list] [ python-Bugs-473456 ] float round up on decimal numbers

noreply@sourceforge.net noreply@sourceforge.net
Sun, 21 Oct 2001 11:30:19 -0700


Bugs item #473456, was opened at 2001-10-21 11:30
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=473456&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Frederic Giacometti (giacometti)
Assigned to: Nobody/Anonymous (nobody)
Summary: float round up on decimal numbers

Initial Comment:

We used to get this right on python 1.5.2; and this breaks since Python 2.0:

>>> for i in range( 10): x = 0.1 * i; print x, str( x), repr( x)
...
0.0 0.0 0.0
0.1 0.1 0.10000000000000001
0.2 0.2 0.20000000000000001
0.3 0.3 0.30000000000000004
0.4 0.4 0.40000000000000002
0.5 0.5 0.5
0.6 0.6 0.60000000000000009
0.7 0.7 0.70000000000000007
0.8 0.8 0.80000000000000004
0.9 0.9 0.90000000000000002
>>> print 0.6 == 0.60000000000000009
0
>>>

>>> 0.3
0.29999999999999999
>>> 0.1
0.10000000000000001
>>> 1.0
1.0
>>> 1.01
1.01
>>> 0.8
0.80000000000000004
>>> 0.5
0.5
>>> 1.3
1.3
>>>

We get the same problem on Unix and Windows; and python1.5.2 gives the exact decimal values 
everywhere.


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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=473456&group_id=5470