Dict handling of floats

Michael Hudson mwh at python.net
Fri Apr 25 06:48:52 EDT 2003


Grant Edwards <grante at visi.com> writes:

> In article <98imn-ust.ln1 at grendel.myth>, Jim Richardson wrote:
> 
> > 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?
> 
> That's floats.  The best you can hope for is "almost right".

Well, in some circumstances you can hope for a bit more than that.
But unless you're very careful, this is probably a good rule of thumb.

Cheers,
M.

-- 
  > It might get my attention if you'd spin around in your chair,
  > spoke in tongues, and puked jets of green goblin goo.
  I can arrange for this.  ;-)            -- Barry Warsaw & Fred Drake




More information about the Python-list mailing list