Rounding a number to nearest even

cokofreedom at gmail.com cokofreedom at gmail.com
Fri Apr 11 07:19:29 EDT 2008


couldn't you just do.

#untested
new_round(n):
  answer = round(n)
  # is answer now odd
  if answer % 2:
    return answer - 1
  else:
    return answer



More information about the Python-list mailing list