Dict handling of floats

Raymond Hettinger vze4rx4y at verizon.net
Fri Apr 25 00:07:20 EDT 2003


[Jim]
> >I have come across a weirdness. I have a number of floats, (lat long
> >pairs) which I stuff into a dict, but when I take them out, my nice %2f4
> >number, (say, 47.5894) is something long and *almost* right, like
> >47.589333333333333339. What gives?

[Mel]
>    Chances are that the float hasn't changed, but that
> you're printing it in a different way.


The Python FAQ has a pretty good explanation:

http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp


Raymond Hettinger






More information about the Python-list mailing list