Movatterモバイル変換


[0]ホーム

URL:


[Python-ideas] math.nextafter

David Mertzmertz 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 severaldifferent but related use cases.  I.e.:    is_close(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> boolI think an additional keyword-only argument for `nextafter_tol` (maybe adifferent spelling) would fit very naturally there.  This would allowsomeone to specify 1 for that degree of closeness, but it would also allowthem to specify some integer larger than 1 without needed to write a loopcalling `nextafter()` repeatedly.Yours, David...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">>https://www.python.org/dev/peps/pep-0485/>> 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; foodfrom the bellies of the hungry; books from the hands of theuneducated; technology from the underdeveloped; and puttingadvocates of freedom in prisons.  Intellectual property isto the 21st century what the slave trade was to the 16th.-------------- next part --------------An HTML attachment was scrubbed...URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170224/9c48fa46/attachment-0001.html>


More information about the Python-ideasmailing list

[8]ページ先頭

©2009-2026 Movatter.jp