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

Chris Barker chris.barker at noaa.gov
Tue Jan 13 00:34:09 CET 2015

On Mon, Jan 12, 2015 at 2:56 PM, Guido van Rossum <guido at python.org> wrote:

> But should probably use complex abs().

maybe, it does add complication  -- I'd need to look more closely at the
Boost code. And I'm trying to think if there are any numerical FP issues
that would arise from that -- I'm no expert.

Adding it to cmath makes sense (if adding it to math happens).


And I hate to bring this up, but any reason for a cmath.nan and cmath.inf ?

I wrote:

> 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"

oops, they do indeed keep both versions, a "weak" and "strong" one.

essentially, "is the error small enough relative to both input values, or
only one of them. Fairly subtle difference, but I like the "strong"
definition, as it gives the same result regardless of input order. though
it does guarantee a bit of maybe unnecessary computation.

I'm going to play with code a bit now.



Christopher Barker, Ph.D.

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 at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150112/a669966e/attachment.html>

More information about the Python-ideas mailing list