str smarter than round?

gods1child alankarmisra at hotmail.com
Fri Jun 15 12:11:04 EDT 2001


What does str() know that round() doesnt in the following lines?

>>> a = 1.69
>>> round(a,2)
1.6899999999999999
>>> round(a,1)
1.7
>>> str(a)
'1.69'
>>> 

How does str manage to get the accurate representation of floating
points? I am using Windows 2000, Python 2.0



More information about the Python-list mailing list