Rounding a number to nearest even

cokofreedom at gmail.com cokofreedom at gmail.com
Fri Apr 11 07:24:35 EDT 2008


On Apr 11, 1:19 pm, cokofree... at gmail.com wrote:
> 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

Whoops, this also affects odd numbers...

Will try and find a GOOD solution later...

Strange request though, why do you need it that way, because 2.5 is
CLOSER to 3 than to 2...



More information about the Python-list mailing list