Float** internal representation (Numeric module)

Andrei project5 at redrival.net
Wed Oct 22 05:16:34 EDT 2003


Alexander Sourjikov wrote:
> Hi pals,
> i am using python for numerical simulations and noticed that
> when i assign a Float variable say 0.1 python sees it like
> 0.10000000149011612.
> I have also checked if python really takes these digits into account and
> it turned out to be truth, because variable * 2 gives
> 0.20000000298023224
> Does anyone have an idea where these weird digits come from and
> how to avoid this strange effect ?

Common problem: floats aren't 100% accurate. See question 4.98 of the 
FAQ or http://www.python.org/doc/current/tut/node14.html.

-- 
Yours,

Andrei

=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V 
ernq gur yvfg, fb gurer'f ab arrq gb PP.







More information about the Python-list mailing list