Rounding error in Python 2.0

sragsdale at my-deja.com sragsdale at my-deja.com
Tue Dec 5 18:06:09 EST 2000


Can anyone explain to me why python2 can't read a float from a string?
Python 1.5.2 didn't have this problem.

[2:58:01pm]bach:/d/bach/proj/gridTools/rnd/ 31> python2
Python 2.0 (#2, Nov 13 2000, 20:09:09)
[GCC 2.95.2 19991024 (release)] on irix646
Type "copyright", "credits" or "license" for more information.
>>> foo = 1242.34
>>> float(str(foo))
1242.3399999999999

[2:58:20pm]bach:/d/bach/proj/gridTools/rnd/ 32> python
Python 1.5.2 (#8, Jul 13 1999, 17:39:45) [C] on irix646
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> foo = 1242.34
>>> float(str(foo))
1242.34


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list