Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Rounding Rules' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Rounding Rules
Authored by: WaltFrench on Dec 12, '05 02:52:24PM
"Five rounds up" is not the only rounding rule -- and in my work it is seldom the best.

My concern is that the total (or average) of rounded numbers shouldn't be biased up or down from the originals. (The total of a column of numbers versus the total of the rounded numbers will be exactly equal only by 1-in-10 chance, but you don't want to do anything so that you expect the total to be consistently higher (or lower) than the originals.

To see the bias, think of rounding 1-digit numbers. Obviously, 12.0 "rounds" to 12 with no bias. Then "pair up" 12.1 with 11.9 -- the 0.1 error introduced by rounding one cancels the negative 0.1 of the other. Ditto 12.2 with 11.8, 12.3 with 11.7 and 12.4 with 11.6. But now... 12.5 with 11.5?

Yes! The point five is just as close to either integer, so you pick up sometimes and down sometimes (and therefore, round without making the total or expected result always bigger or smaller). The best-known way is to round to the nearest even number when you have a point 5. 12.5 rounds to 12, as does 11.5. 73.5 and 74.5 both round to 74.

If point 5 always rounds up, here's the bias: nine numbers out of ten have no net up- or down-bias, but one number out of 10 (the ones that end in point 5) rounds to a result that's 0.5 bigger than the source, for an expected increase of 0.05. "Round to nearest/even" introduces no bias.

For jumping more than one decimal at a time, the rule is that only point 5000000... gets the "to even" handling. 12.5002 rounds to 13. 12.4998 rounds down to 12.

I used Excel to create 3000 random numbers between 0 and 100, then rounded them to one digit (with Excel's ROUND function, which rounds fives up). The total of the original and rounded column was close -- just a difference of 1.01 out of 151,829. That's what you expect when you're scrapping about 15 decimal places all at once -- the rounding rule hardly matters. But then I rounded the single-decimal-place numbers to zero places, and the total of those grew by 153.9 -- essentially, the expected 0.05 average bias per number.

Rounding to nearest/even works especially well when multiple rounding is applied. If you repeat "five rounds up," knocking off one digit at a time, the typical bias will be almost 0.1, twice the 0.05 I mentioned above.

BTW, the IEEE, which sets standards for math on CPU's etc., lists 4 rounding modes. Round to nearest/even is the default for X86 and PPC -- probably, for most applications. There are thorny issues about some types of binary calculations but my description is fine for by-hand work and should match what you see from most programs that (stupidly) try to outsmart their CPU's. (This is only one of a long list of Excel's dumb math handling.))

[ Reply to This | # ]
Rounding Rules
Authored by: JonathanBoyd on Dec 12, '05 03:23:06PM

Rounding away from zero, which is what rounding up usually is, should have no net effect on the mean if you have both positive and negative numbers. If you're only using one of those though, then rounding to even certainly seems to be a better way to get the mean.



[ Reply to This | # ]
Rounding Rules
Authored by: porkchop_d_clown on Dec 12, '05 09:49:03PM

I can't imagine many common problems where the median value is zero.

Still, for most purposes the difference between the two algorithms is immaterial. If you need more precision, you should use a larger word size. ;-)

I actually just went through this with my 3rd grade daughter - I learned the even/odd rule growing up, they just taught her the round-away-from-zero rule. This caused some confusion in homework checking.

---
Everyone loves a clown, but no one will lend him money!



[ Reply to This | # ]