Rounding a number to nearest even
Mark Dickinson
dickinsm at gmail.com
Fri Apr 11 21:27:43 CEST 2008
On Apr 11, 2:33 pm, Lie <Lie.1... at gmail.com> wrote:
> In this table, we consider that a number is rounded down when the
> number is equal to truncated value (the number without fractional
> part), while round up is equal to truncated value + 1 or truncated
> value -1 if value is negative (Actually this is not round-half-up
> algorithm, it's a round-half-away-from-zero algorithm, but lets just
> consider that to be the same for now). In this revised table, you get
> 10 round ups and 10 round down (i.e. Average Rounding Error == 0),
> while by rounding to nearest even you get 9 round up and 11 round down
> (i.e. Average Rounding Error != 0).
No: if you interpret average to mean 'mean' (add up the (signed)
rounding errors from the 20 cases you list and divide by 20) you'll
find that the average rounding error is indeed 0 for round-half-to-
even,
and 0.05 for round-half-away-from-0, just as Mikael said.
> Another mistake, in an unquantized value the probability of getting
> exactly 0.5 (or any other number specified) is not 0 but an
> infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO))
I'm not sure you'll get many takers for this point of view. If X is
a random variable uniformly distributed on the interval [0, 1) then
the probability that X == 0.5 is indeed exactly 0, using conventional
definitions. (And if you're not using conventional definitions, you
should say so....)
Mark
More information about the Python-list
mailing list