On Jul 28, 12:34 am, Gary Herron <[EMAIL PROTECTED]> wrote: > This will work as you wish: > math.floor(x+0.5)
This works fine for positive x but what about negative:
>>> round(2.5)
3.0
>>> floor(2.5 + 0.5)
3.0
>>> round(-2.5)
-3.0
>>> floor(-2.5 + 0.5)
-2.0
Maybe:
def round2(x):
return math.floor(x + (0.5 if x >= 0 else -0.5))
--
http://mail.python.org/mailman/listinfo/python-list
