Re: Rounding??



[Nicholas Lee]

  On Tue, Jun 12, 2001 at 09:18:03PM +0200, Kjetil Torgrim Homme wrote:
  > Correct rounding is difficult.  If a value falls exactly between the
  > two candidates, it should choose the candidate which is _even_.
  
  I always thought than even given that 5 is equal distance from
  either 0 or 10, that it was conventional to round up.

Yes, it's conventional, but it introduces a bias.  Adding up the rounded
numbers should ideally give the same result as rounding the sum of the
full precision.

  0.5 + 1.5 + 2.5 + 3.5 ==  8
   0  +  2  +  2  +  4  ==  8
   1  +  2  +  3  +  4  == 10

The "round towards even" algorithm can perform as bad as "round up",
but never worse, and usually much better.


Kjetil T.




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