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

Andrew Barnert abarnert at yahoo.com
Sun Jan 18 22:02:02 CET 2015

On Jan 18, 2015, at 12:14, Chris Barker <chris.barker at noaa.gov> wrote:

> There are cases where ULPs, etc are key -- those are for testing precision of algorithms, etc, and I think a special use case that would require a different function -- no need to try to cram it all into one function.

I think the right answer there is to add a float_difference that follows the same rules as the IEEE/C/POSIX nextafter function and friends. (And also maybe to add nextafter and friends--note that decimal already has similar functions, but named with underscores.) With that, it's trivial to add ulps-based tests; without it, it's very hard.

And then ulps can be removed from the discussion on absolute and relative error.

More information about the Python-ideas mailing list