str smarter than round?
Tim Peters
tim.one at home.com
Fri Jun 15 13:53:48 EDT 2001
[gods1child]
> 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
Congratulations! You've elected yourself to be a guinea pig for reading
this new Tutorial Appendix:
http://python.sourceforge.net/devel-docs/tut/node14.html
never-ask-a-question-unless-you-really-want-an-answer<wink>-ly y'rs - tim
More information about the Python-list
mailing list