Float precision and float equality

sturlamolden sturlamolden at yahoo.no
Sat Dec 5 19:31:05 EST 2009


On 5 Des, 16:37, Anton81 <gerenu... at googlemail.com> wrote:
> I'd like to do calculations with floats and at some point equality of
> two number will be checked.
> What is the best way to make sure that equality of floats will be
> detected, where I assume that mismatches beyond a certain point are
> due to truncation errors?


isequal = lambda x,y : abs(x-y) < eps

where eps is the truncation error.






More information about the Python-list mailing list