rounding problem

Michael Hartl mhartl at post.harvard.edu
Wed Feb 23 22:29:25 EST 2005


> Is it normal?

Yes.  The interpreter prints back the repr of a, which reflects the
imprecision inherent in floats.  If you want '1.1', use the string
returned by the str function.

>>> a = 1.1
>>> a
1.1000000000000001
>>> repr(a)
'1.1000000000000001'
>>> str(a)
'1.1'

Michael

--
Michael D. Hartl, Ph.D.
CTO, Quark Sports LLC
http://quarksports.com/




More information about the Python-list mailing list