tags:

views:

301

answers:

3

Hi, I am told that ROUND_HALF_EVEN is the favored rounding mode for financial data calculations. I am curious to know why and how this rounding mode would reduce the cumulative error as stated in javadoc BigDecimal 1.4.2. Thanks, Dean

+1  A: 

From Wikipedia:

Despite the custom of rounding the number 4.5 up to 5, in fact 4.5 is no nearer to 5 than it is to 4 (it is 0.5 away from both). When dealing with large sets of scientific or statistical data, where trends are important, traditional rounding on average biases the data upwards slightly. Over a large set of data, or when many subsequent rounding operations are performed as in digital signal processing, the round-to-even rule tends to reduce the total rounding error, with (on average) an equal portion of numbers rounding up as rounding down. This generally reduces upwards skewing of the result.

maxyfc
+2  A: 

Just to clarify "round half even" rounds .5 up if the non decimal part of the number is even and rounds it down if the non dcimal part is odd.

So 4.5 -> 5, 5.5 -> 5, 6.5 -> 7 etc.

For a truly random set of decimal numbers this type of rounding will not skew the totals up or down significantly. So it is favoured as a "fair" rounding system in financial applications.

James Anderson
A: 

My impression is the same as the other two answers, namely that round-half-even when applied to a random number is equally likely to round up or down, so that over large sets of data there is no expected offset due to rounding. But as far as I know, there's nothing special about round-half-even itself; round-half-odd (round n.5 to the nearest odd integer) would, I think, have the same property. Same with a random rounding policy, i.e. n.5 gets rounded up or down randomly with 50% probability.

David Zaslavsky
round half odd introduces a slight bias away from zero.
Steve Bosman
good point, thanks
David Zaslavsky