Float precision and float equality

Raymond Hettinger python at rcn.com
Sun Dec 6 04:12:18 EST 2009


On Dec 5, 11:42 pm, Tim Roberts <t... at probo.com> wrote:
> Raymond Hettinger <pyt... at rcn.com> wrote:
>
> >   if not round(x - y, 6): ...
>
> That's a dangerous suggestion.  It only works if x and y happen to be
> roughly in the range of integers.

Right.  Using abs(x-y) < eps is the way to go.


Raymond



More information about the Python-list mailing list