Steven D'Aprano <[EMAIL PROTECTED]> writes: > 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.
I think you have to do it by bit twiddling. But something like bisection search could come pretty close, for well-behaved values of x: def nextfloat(x): dx = (x, x/2.0) while x+dx[1] != x: dx = (dx[1], dx[1]/2.0) return dx[0]+x -- http://mail.python.org/mailman/listinfo/python-list