Game Development Community

Round to Nearest Even

by Mike Nelson · in Technical Issues · 12/10/2002 (10:01 am) · 4 replies

A rounding technique that is often used in finance and statistics seems to be to round off a number to the nearest even number when you are between the significant digits to round to.

For instance when using this technique, rounding to the integer value:
round(1.5,0) = 2
 round(4.5,0) = 4
 round(7.5,0) = 8
 round(8.5,0) = 8

This is a bit different than what is usually taught in school which is to always round up in this situation. I've seen mention that this is statistically more accurate like here. But I don't see how.

Seems like the odd numbers would get left out of the distribution a bit with this rule and that the traditional round up rule would actually be more accurate statistically.

Anyone know why this is?

Thanks,
Mike

#1
12/10/2002 (10:25 am)
The problem is that you introduce a small error by rounding a .5 If you always round up, then your error will accumulate.

The idea is that this error will tend _not_ to accumulate if you round up half the time and round down half the time. Finance seems to have partitioned the round up/down case by rounding to evens.

In physics, the common practice is to alternate rounding up and down of .5s, but that requires some knowledge of state that accountants would apparently rather not be bothered with.
#2
12/10/2002 (11:01 am)
Cool. That makes sense.
#3
02/05/2003 (6:57 am)
The reason is that the difference between two following numbers is 1.0 /2 would be 0.5

But this does not take into account that the number itself is included in the difference.

If you count in 1/10:

1.0, 1.1, 1.2, ..., 2.0

There just 9 times 0.1 differences, the 10th actualy is 2.0 itself.
#4
02/05/2003 (11:20 am)
I have found that if you avoid statistics like a big dog with snarling teeth then you can't go wrong!

Seriously though, I agree with Mark, although the classic "mFloor(n + 0.5)" has served me well over the years. :)

- Melv.