On Mon, Jan 12, 2015 at 12:04 PM, Guido van Rossum <guido@python.org> wrote:
So is 1e-100 close to 1e-50 with the default tolerance? What about 1e+100 and (1e+100 plus one ulp)?

sorry I should have not specified a specific default, and/or explained more what I think it should mean.

But I thought the first question was "might this be a good idea for the standard library" -- and only if so, then we can work out how to do it.

But anyway, the while point is that it would be some version "relative error", NOT an absolute tolerance -- that is pretty easy to write.

See Nathaniel's note for the too many options already in numpy.

Nathaniel Smith wrote:

Unfortunately this opens a tremendous can of worms.

Well, yes, but something generally useful for many cases would still be nice.

Boost has thought about this a lot and advocates a slightly different
definition (actually, two slightly different definitions) from any of
the above:
   http://www.boost.org/doc/libs/1_34_0/libs/test/doc/components/test_tools/floating_point_comparison.html


It looks like they start with two, but end up with

"the implementation is using modified version of the equations (1) and (2) where all underflow, overflow conditions could be guarded safely"

That looks good to me, and the origins in Knuth are a good sign.

-Chris


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov