Rounding a number to nearest even

Chris cwitts at gmail.com
Tue Apr 15 06:33:03 EDT 2008


On Apr 15, 11:47 am, Duncan Booth <duncan.bo... at invalid.invalid>
wrote:
> Chris <cwi... at gmail.com> wrote:
> > even is closer to even.75 than even+1.25.  Why should it be rounded
> > up ?
>
> Because the OP wants to round values to the nearest integer. Only values of
> the form 'x.5' which have two nearest values use 'nearest even' to
> disambiguate the result.
>
> Seehttp://en.wikipedia.org/wiki/Rounding#Round-to-even_method
>
> That's the way I was taught to round numbers when at primary school.

My bad, didn't see he only wanted for halves and handle others as
normal.



More information about the Python-list mailing list