[Python-bugs-list] [Bug #127483] repr and str return different results for a some floats
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 03 Jan 2001 22:00:18 -0800
Bug #127483, was updated on 2001-Jan-03 22:00
Here is a current snapshot of the bug.
Project: Python
Category: Python Interpreter Core
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: nobody
Assigned to : nobody
Summary: repr and str return different results for a some floats
Details: I was getting some strange result when converting between strings
and floats for doing calculations and discovered that it was happening when
executing the following code.
def test_float( a_float ) :
print a_float, str( a_float ), repr( a_float )
if __name__ == '__main__' :
test_float( 0.01 )
test_float( 0.02 )
test_float( 0.03 )
test_float( 0.04 )
test_float( 0.05 )
test_float( 0.06 )
test_float( 0.07 )
RESULTS
0.01 0.01 0.01
0.02 0.02 0.02
0.03 0.03 0.029999999999999999
0.04 0.04 0.040000000000000001
0.05 0.05 0.050000000000000003
0.06 0.06 0.059999999999999998
0.07 0.07 0.070000000000000007
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=127483&group_id=5470