[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: operation of 'round' function. Why does it matter?

From: David Kastrup
Subject: Re: operation of 'round' function. Why does it matter?
Date: 09 Feb 2002 15:06:09 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

address@hidden (Alan Mackenzie) writes:

> Deepak Goel <address@hidden> wrote on 08 Feb 2002 11:28:38 -0500:
> >> 
> >> So, if it is 2.5, you round to 2, but, if it is 3.5, you round to 4??
> > well, yes.  that's the convention i have seen more than any other.
> > if you have a large data of numbers to be rounded, this method ensures
> > that you do not change the mean..
> Of course you change the mean.  What you mean, I think, is that the mean
> of the change of the mean is zero.

Yes.  Unbiased.

> Why on earth does it matter?  Any time you're doing rounding, truncating,
> flooring, or whatever, you're fudging the result and loosing
> accuracy.

"Losing", for heaven's sake, "losing".  The art of numerics is to lose
as little accuracy as possible.  Rounding to even in number bases
divisible by 2 but not by 4 rounds away from the next possible point
of ambiguity.  That way, a subsequent rounding operation will in
several cases not continue to add error in the same direction in case
of another occuring ambiguity.  This means, for example, that a+b-b =
a+b-b+b-b (bad enough that a+b-b = a does not hold).  In case where
you are, say, approximating an integral by summing differences, not to
be sneezed at.  If adding 10000 values already introduces a bias of

There is a reason the IEEE mandates rounding to even.  Now of course
you may feel free to point out that what a floating point processor
does with its least significant digits need not have any correlation
to what a function round() supposed to deliver whole numbers does.
But what and how numbers are used is probably not always easy to

David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]