newbie: precision question

Lada Kugis lada.kugis at
Sat Mar 21 04:12:48 CET 2009


I'm a newbie learning python, so forgive for, what may seem to some,
like a stupid question.

I understand the basic integer and fp type, but what I'm having a
little trouble are the long type and infinite precision type.

Also, when I do

>>> math.pi - (math.sqrt(math.pi))**2.

I get

>>>4.4408920985006262e-016

Please, could someone in just a few words, in newbie speak, explain
why does that happen ? And what do the types actually mean ? What I
mean, how can something have infinite precision but still not return
zero as a result. (Btw, I always thought floating points had precision
up to 8 significant digits, doubles 16).

Nice regards
Lada



More information about the Python-list mailing list