xaktly | Science | Statistics

Rounding rules


You probably know these, but maybe there's more ...


Rounding numbers is necessary, so knowing how to round properly is important. It may not be quite as simple as you think, but don't worry; it's still pretty easy.

Computers often operate with 64 bits or more of precision. Leaving off one bit for the sign of a number, the largest negative or positive integer that can be represented is 263, or over 1018. When we work with floating point (decimal) numbers and powers of ten, that gives us a tremendous amount of precision, which the computer needs to do sophisticated calculations, but which we usually neither need nor want when reporting results ... so we round.

You probably already know most of what you know about rounding, but let's review, and take a look at a modification that can make rounding less biased.

Intel Xeon™ processor


The usual rule


It's likely that you learned a very simple rule for rounding: If the last digit before the place you'd like to round is 5, round up. Otherwise, round down. For example, here is a list of numbers rounded to the hundredths place:

These are perfectly fine and follow the rule.

The basic rule is that if we want to round to the nth decimal place, we consider the number in the (n + 1)th place. If that number is 4 or less, we keep the number as is and just truncate it. If that number is 5 or greater, we round the nth place up by one digit. Done.

However, as we'll see below, there's a bit of bias that's introduced in that decision, and we always want to avoid any bias when working with data. Fortunately, there's a simple modification we can make to our procedure as unbiased as it can be.


Rounding up on 5 vs. rounding to the even on 5


Consider the table here. On the left are two groups of numbers to the thousandths place, 0.110, 0.111, and so on. We'll round those numbers to the hundredths place (which we'll call the "target digit," to 0.11, and so on.

The second column is those original numbers rounded using the "up on 5" rule. Numbers highlighted in green were rounded down, while numbers highlighted in pink were rounded up.

Notice that there are two groups of numbers, one with the second digit odd (= 1) and the lower group with the second digit even (= 2). Notice further that the numbers 0.110 and 0.012 are unchanged in any process of rounding to the hundredths place.

So the second column shows that for both groups (for either even or add numbers in the hundredths place), we round down four times and up five times. Unfortunately, this introduces a bias in our rounding. 10% of our numbers won't change, 40% will be rounded down and 50% will be rounded up.

Rounding to the even on 5

In the third column, the rounding rule has been changed to "if the (n + 1)th digit is 5, round up to the next even, unless the nth digit is already even, then truncate."

Now notice that when the hundredths digit is odd, we round down four times and up five times, but when the hundredths digit is even, we round down five times and up four times. Over the course of all possible hundredths digits (0, 1, 2, ... , 9), we even out to a 50/50 chance of rounding up/down on 5 — no more bias. This is the preferable way to round numbers, and it doesn't take any more time than the round-up on 5 method.

Rounding rules

When rounding to the nth decimal place, consider the (n + 1)th digit.

  • If the (n+1)th digit is less than 5, truncate the number to the nth place

  • If the (n+1)th digit is greater than 5, round the nth digit up by one.

  • If the (n+1)th digit is 5, then
    • If the nth digit is even, leave it and truncate.

    • If the nth digit is odd, round up to the next even number.

Practice

Here are a few practice numbers to round to the 1/100ths place. The red solutions are cases where we need to round to the nearest even digit.

Number Rounded
4.506 4.51
0.833 0.83
9.018 9.02
1.095 1.1
6.981 6.98
5.371 5.37
6.942 6.94
2.215 2.22
1.102 1.01
5.943 5.94
Number Rounded
8.419 8.42
9.973 9.97
5.066 5.07
9.925 9.92
2.430 2.43
9.020 9.02
6.885 6.88
5.585 5.58
0.355 0.36
7.447 7.45

X

bias

Bias means favor or prejudice in favor of one thing and against another. When working with data, we try not to let our own or any other biases affect decision-making.

X

truncate

To truncate is to cut off. The limb of a tree can be truncated by cutting it shorter. When we truncate a number like 2.995 to the hundredths place, it becomes 2.999, which is different from the result we'd get by rounding.

Creative Commons License   optimized for firefox
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2016, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.