Python float representation error?

James Stroud jstroud at
Mon Mar 27 02:02:01 CEST 2006

mailpitches at wrote:
> try running this in python:
> print [39.95]
> the output i get is:
> [39.950000000000003]
> what's up with that?

This comes from the imprecision in representing base-10 fractions as 
binary. Try "print [str(39.95)]".

If you want to print a list, maybe:

print map(str, alist)


James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

More information about the Python-list mailing list