Next float?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Nov 21 22:04:41 EST 2007


Is there a simple, elegant way in Python to get the next float from a 
given one? By "next float", I mean given a float x, I want the smallest 
float larger than x.

Bonus points if I can go in either direction (i.e. the "previous float" 
as well as the next).

Note to maths pedants: I am aware that there is no "next real number", 
but floats are not reals.


-- 
Steven



More information about the Python-list mailing list