mertz at gnosis.cx
Fri Feb 24 20:29:15 EST 2017
Marc-André slightly misspelled the recent-ish addition of math.isclose(),
but I agree that it is absolutely where a "nextafter" belongs.
The function signature is already relatively complex to cover several
different but related use cases. I.e.:
is_close(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool
I think an additional keyword-only argument for `nextafter_tol` (maybe a
different spelling) would fit very naturally there. This would allow
someone to specify 1 for that degree of closeness, but it would also allow
them to specify some integer larger than 1 without needed to write a loop
calling `nextafter()` repeatedly.
On Fri, Feb 24, 2017 at 5:29 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> Perhaps closeto() could be extended to address the use case:
> "Match anything within N number of smallest float representable
> intervals around float value x"
> This could then be used to detect cases where it doesn't
> make sense to run additional rounds of refinement to
> find roots or local minima, since IEEE floats simply don't
> provide enough accuracy to dig deeper.
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas