[Python-ideas] Way to check for floating point "closeness"?

Chris Barker - NOAA Federal chris.barker at noaa.gov
Wed Jan 14 04:25:26 CET 2015


> On Jan 13, 2015, at 6:58 PM, Ron Adam <ron3200 at gmail.com> wrote:
>>  maybe we could specify an absolute
>> tolerance near zero, and a relative tolerance elsewhere, both at once.
>> Tricky to document, even if possible.
>
> Doesn't this problem come up at any boundary comparison, and not just zero?

Zero is special because you lose the ability to use a relative
tolerance. Everything is huge compared to zero.

> So isn't the issue about any n distance from any floating point number that is less than 1 ulp?

I'm still a bit fuzzy on Ulps, but it seems the goal here is to define
a tolerance larger than an ulp.  This is for the use case where we
expect multiple rounding errors -- many more than one ulp,

That's why I think the use case for ulp comparisons is more about
assessment of accuracy of algorithms than "did I introduce a big old
bug?" or, "is this computed value close enough to what I measured?"

-Chris


More information about the Python-ideas mailing list