Next float?

Robert Kern robert.kern at gmail.com
Thu Nov 22 01:42:38 EST 2007


Steven D'Aprano wrote:
> 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.

Courtesy of Tim Peters:

  http://mail.python.org/pipermail/python-list/2001-August/099152.html

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

Left as an exercise for the reader.  :-)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list