Rounding a number to nearest even

Mark Dickinson dickinsm at
Sun Apr 13 16:28:22 CEST 2008

On Apr 13, 4:18 am, Lie <Lie.1... at> wrote:
> it and there is nothing else in it, but in the second number range
> (barely above 1 to 2) the number 1.0 is not included while the number
> 2.0 is contained in it, clearly not a clean separation of numbers in
> the form of y.x where y is pre-determined and x is variable from other
> possible values of y.

Have you considered the fact that the real numbers of
the form 1.xxxxx... are those in the range [1.0, 2.0],
including *both* endpoints?  That is, 2.0 = 1.999999...
Similarly, the midpoint of this range can be written
both in the form 1.500000... and 1.499999...

This is relevant if you think of rounding as an operation
on *decimal representations* of real numbers rather than
as an operation on real numbers themselves.  I'm not sure
which point of view you're taking here.

Either way, your arguments don't change the fact that the
average rounding error is strictly positive for positive
quantized results, under round-half-away-from-zero.


More information about the Python-list mailing list