Dict handling of floats

Grant Edwards grante at visi.com
Fri Apr 25 10:32:51 EDT 2003


In article <7h3fzo6luno.fsf at pc150.maths.bris.ac.uk>, Michael Hudson wrote:
> 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.

Yes, but only the timbot and three other people on the planet
(who refuse to be named) know what those circumstances are
ahead of time.  The rest of us settle for being able to figure
out what went wrong afterwards.

> But unless you're very careful, this is probably a good rule of
> thumb.

-- 
Grant Edwards                   grante             Yow!  FIRST, I'm covering
                                  at               you with OLIVE OIL and
                               visi.com            PRUNE WHIP!!




More information about the Python-list mailing list