gh-94906: Support multiple steps in math.nextafter (#103881)

This PR updates `math.nextafter` to add a new `steps` argument. The behaviour is as though `math.nextafter` had been called `steps` times in succession.

---------

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
This commit is contained in:
Matthias Görgens 2023-05-20 04:03:49 +08:00 committed by GitHub
parent c3f43bfb4b
commit 6e39fa1955
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 223 additions and 18 deletions

View file

@ -224,11 +224,11 @@ Number-theoretic and representation functions
of *x* and are floats.
.. function:: nextafter(x, y)
.. function:: nextafter(x, y, steps=1)
Return the next floating-point value after *x* towards *y*.
Return the floating-point value *steps* steps after *x* towards *y*.
If *x* is equal to *y*, return *y*.
If *x* is equal to *y*, return *y*, unless *steps* is zero.
Examples:
@ -239,6 +239,9 @@ Number-theoretic and representation functions
See also :func:`math.ulp`.
.. versionchanged:: 3.12
Added the *steps* argument.
.. versionadded:: 3.9
.. function:: perm(n, k=None)