This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients lemburg, mark.dickinson, rhettinger, stutzbach, tim.peters, vstinner
Date 2020-01-11.02:42:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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
    nextAwayFromZero(-0.0) == -5e-324
Date User Action Args
2020-01-11 02:42:59tim.peterssetrecipients: + tim.peters, lemburg, rhettinger, mark.dickinson, vstinner, stutzbach
2020-01-11 02:42:59tim.peterssetmessageid: <>
2020-01-11 02:42:59tim.peterslinkissue39288 messages
2020-01-11 02:42:59tim.peterscreate