Dec-11-2021, 05:32 AM
Not exactly, but the
The
math
module provides the function nextafter(x,y)
that returns the next floating-point value after x towards y.>>> math.nextafter(12,0) # The next float towards 0. 11.999999999999998 >>> 12-math.nextafter(12,0) 1.7763568394002505e-15 >>> _.hex() '0x1.0000000000000p-49' >>>Naming isn't really consistent.
The
decimal
provides context methods called next_plus
, 'next_minus, and
next_towards`.gmpy2
uses the names next_above
and next_below
.