Message359775
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 |
|
Date |
User |
Action |
Args |
2020-01-11 02:42:59 | tim.peters | set | recipients:
+ tim.peters, lemburg, rhettinger, mark.dickinson, vstinner, stutzbach |
2020-01-11 02:42:59 | tim.peters | set | messageid: <1578710579.92.0.0323900426704.issue39288@roundup.psfhosted.org> |
2020-01-11 02:42:59 | tim.peters | link | issue39288 messages |
2020-01-11 02:42:59 | tim.peters | create | |
|