Tim Peters <[email protected]> added the comment:
No doubt that something along these lines would be useful.
`nextafter()` is too widely implemented to fight against, despite the sucky
name ;-)
I believe the rest should be straightforward (for those who want them) to do
with one-liners, so there's not much of a case for building them in. Or is
that wrong? My guesses for correct implementations:
def nextUp(x):
return math.nextafter(x, math.inf)
def nextDown(x):
return math.nextafter(x, -math.inf)
def nextAwayFromZero(x):
return math.nextafter(x, math.copysign(math.inf, x))
That last assumes you want -0 and +0 to act differently; i.e., want
nextAwayFromZero(0.0) == 5e-324
and
nextAwayFromZero(-0.0) == -5e-324
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39288>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com