A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/060534.html below:

[Python-Dev] math.areclose ...?

[Python-Dev] math.areclose ...?Scott David Daniels Scott.Daniels at Acm.Org
Wed Feb 8 17:11:55 CET 2006
Smith wrote:
> ... There is a problem with dividing by 'ave' if the x and y are at 
 > the floating point limits, but the symmetric behaving form (presented
 > by Scott Daniels) will have the same problem.
Upon reflection, 'max' is probably better than averaging, and avoiding
divide is also a reasonably good idea.  Note that relative_tol < 1.0
(typically) so underflow, rather than overflow, is the issue:

     def nearby(x, y, relative_tol=1.e-5, absolute_tol=1.e-8):
         difference = abs(x - y)
         return (difference <= absolute_tol or
                 difference <= max(abs(x), abs(y)) * relative_tol)

I use <=, since "zero-tolerance" should pass equal values.

--Scott David Daniels
scott.Daniels at Acm.Org

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4