Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Sometimesmath.nextafter() needs to be applied multiple times in succession.
x = nextafter(nextafter( nextafter(x, inf), inf), inf) # Three steps upIt would be nice if the function supported this directly:
x = nextafter(x, inf, n=3)The implementation would just be a for-loop:
def newnextafter(x, y, /, *, n=1): 'Return the floating-point value n steps after x towards y.' for i in range(n): x = nextafter(x, y) return xThe formal paramater can be justn or the longer but more descriptivesteps.