Python float representation error?
James Stroud
jstroud at ucla.edu
Sun Mar 26 19:02:01 EST 2006
mailpitches at email.com 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
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
More information about the Python-list
mailing list