The Art of Rounding

A High-Level Investigation on an Elementary Topic

Kevin Shi
The Quantastic Journal
11 min readJul 16, 2024

--

Rounding. It’s one of those things that gave you a headache on elementary school tests. The average adult finds this concept hilariously simple, being one of the few mathematical tools that people use on a daily basis.

You’re right: it’s simple, you learnt it together with addition and subtraction, and it’s grocery-store math. Yet, it is also used in higher mathematics, in supercomputing, in rocket science…

That’s all too advanced for this story. Today, we’ll look at the considerations involved in everyday rounding, starting from plain-old numbers and extending to deeper mathematical thinking.

Outline

  1. Absurd Claims
  2. Why Math Causes Fights
  3. Progressive Rounding
  4. Medium’s View Counter

(1) Absurd Claims: How 46 – 45 = 0

Typically, we round in base-10, and we’re going to stick to that for today. In base-10, the rounding half up scheme is used, So 25.5 would be 26 and 25.4 would be 25. Of course, we can round half down, which is another tie-breaking method. This way, 25.5 would be 25 and 25.6 would be 26.

That seems fine, but there’s a problem: these rounding schemes are not universally applicable; in fact, they are inconsistent and self-contradictory. Why? The following example demonstrates this:

I lend Sherlock 45.5 dollars. Sherlock now has 45.5 dollars, and I have -45.5 dollars (compared to what I initially had). Rounding half up, Sherlock has 46 dollars, and I have -45 dollars.

Photo by Markus Spiske on Unsplash

Do you notice the problem? They don’t even sum up to zero!

That’s not the only problem. Typically, we expect rounding to be within half the rounding precision: e.g., for 1573:

  1. Rounding to the tens place gives:
    1570, and 1573 – 1570 < 5 = 10 / 2
  2. Rounding to the hundreds, place gives:
    1600, and 1600 – 1573 < 50 = 100 / 2
  3. And so on for the thousands place with:
    2000 – 1573 < 1000 / 2

Rounding half up doesn’t stay within half the rounding precision for negative numbers, and rounding half down doesn’t stay within half the rounding precision for positive numbers.

Mathematicians hate these scenarios, so they created something symmetric (so the numbers add up to zero in these cases). Instead of rounding up or down, we round towards or away from zero.

  • Rounding towards zero: rounding down for positive numbers, and rounding up for negative numbers
  • Rounding away from zero: rounding up for positive numbers, and rounding down for negative numbers

In reality, this corresponds to rounding up or down absolute values of numbers. You should verify that this allows a sum of zero in the previous problem and preserves the symmetry of the numbers.

In particular, rounding away from zero always stays within half the rounding precision. Can you see why?

(2) Why Math Causes Fights: zero equals infinity

Going back to me and Sherlock:

I give Sherlock a 1.5 million dollar loan. Sherlock now has 1.5 million dollars, and I have -1.5 million dollars. Rounding towards zero, Sherlock has 1 million dollars, and I have -1 million dollars.

Photo by DocuSign on Unsplash

Seems alright; at least the numbers are balanced. But when Sherlock is coming to return my money, he only gives me 1 million. I immediately lost 500000 dollars!

That seemed unfair to me. Changing things up,

I give Sherlock a 1.5 million dollar loan. Sherlock now has 1.5 million dollars, and I have -1.5 million dollars. Rounding away from zero, Sherlock has 2 million dollars, and I have -2 million dollars.

I just earned an extra 500000 dollars, but Sherlock wants to murder me!

Normally, rounding is used when we lose or gain something unimportant. However, in these cases, the losses/gains are immense. We need a way to recover the original values.

Although we can do this when we have numbers like 1.5, 2.5, 3.5, it isn’t possible for other less “friendly” numbers. We propose a method to minimize the expected error of recovery:

  1. If rounding to and away from zero gives distinct values, take their average.
  2. If rounding to and away from zero gives the same values, stick with the number.

Since “to” and “away” are tiebreaking rules, they only give different results when the actual value is at the center of the two rounded numbers. In the first situation, the method gives the exact value. In the second situation, there is equal chance of deviating towards the smaller and the larger sides. The expected deviation is 0.

Odd and Even

Notice that there’s always some bias regardless of the method we chose; The bias was only resolved when two rounding methods were combined. However, there’s actually a rounding method without positive/negative bias and without bias towards/away from zero, though a new type of bias will be introduced: odd/even bias.

Yes, we can round to even (or odd)! If the fractional part being rounded is 0.5, then we round it to the nearest even number; likewise, we can round them to the nearest odd number. If the fractional part is not 0.5, then there’s no need for tie-breaking, and we round as normal.

Since the evens (and odds) are evenly distributed, there’s an equal proportion of numbers being rounded to/away from 0, and an equal proportion of numbers being rounded up/down. The only bias present is that there’s a greater likelihood of finding even (or odd) numbers, more precisely, by 1/20 when compared to typical rounding half up.

(3) Progressive Rounding

No one uses this method, but it has some interesting properties. Credits to AkashChowdhury93 for “inventing” this method.

Progressive rounding is an iterative process; rounding each digit starting from the right until a desired precision is reached. For instance,

  • Progression away from 0: 12345 → 12350 → 12400 → 12000 → 10000.
  • Progression towards 0: 12345 → 12340 → 12300 → 12000 → 10000.

A property that makes this scheme similar to the typical rounding scheme is that it can be used to determine the “wholeness” of numbers. That is,

If a + b = c where c is a nonzero integer with n trailing zeros, c = a (rounded to the kth digit) + b (rounded to the kth digit) if and only if kn + 1.

To prove this, we have to introduce a new rounding scheme, a variant of alternating tie breaking. This means that when encountering 5, we alternate rounding it up or down. In our situation, this alternation is between two numbers: for instance, if one number is 15 and the other is 25, we can round 15 to 20 and round 25 to 20 OR round 15 to 10 and 25 to 30.

Photo by Tingey Injury Law Firm on Unsplash

Now, we first show that kn works: Let a, c and b, d be the numbers at the kth and (k – 1)th digits, respectively. Then, we discuss two scenarios (we only discuss positive numbers because alternation doesn’t have bias):

  1. If ab and cd satisfy ab + cd = __0, then ab (rounded) + cd (rounded) = ab + cd = __0. The rounding here is to the nearest tens.
    Proof: If b = d = 0, then it is obvious since a + b remains unchanged. If b and d are nonzero, then ab (rounded) + cd (rounded) = 10a + 10c + 10. Since b + d = 10, the proof is complete.
  2. If a’b’ and c’d’ satisfy (a’b’ + 1) + c’d’ = __0, take ab = a’b’ + 1 (keeping the last two digits), hence (a’b’ + 1) (rounded) + c’d’ (rounded) = (a’b’ + 1) + c’d’ = __0.
    Proof: Notice that we’re restricted to b’ + d’ + 1 = 10. If b’ + 1 < 10, then just proceed as before. If b’ + 1 = 10, then d’ = 0, and (a’b’ + 1) (rounded) + c’d’ (rounded) = 10a’ + 10c’ + 10 = (a’b’ + 1) + c’d’. The proof is complete.

These cover all situations encountered by the last unrounded digits of a and b. Since the sum remains the same after each step in the rounding, the final sum will still be c. Now we prove the “and only if” part.

Let's say we’ve rounded to the (n + 1)th digit, and now we begin rounding the (n + 2)th digit. Then, both of the numbers at the (n + 1)th digits will become zero, and since we know the (n + 1)th digit of c isn’t zero, this isn’t possible.

The Reasonable Ineffectiveness

It is intuitive that rounding more times leads to more room for error. However, is this actually true? We’ve seen from the above proof that rounding progressively could have some nice properties. In addition, progressive rounding gives us more information about previous digits.

Now, we give a mathematical proof that progressive rounding generally “fails”.

We want to round a positive number n to its kth digit. Denote by n’ = truncate(n) the truncation of n to the (k - 1)th digit, and by n’’ the progressive rounding of n to the (k - 1)th digit through rounding up. Choose the “round half up” tie-breaking scheme.

  1. If n’ = n’’, then both rounding schemes yield the same result.
  2. If n’ < n’’ and the tie-breaking scheme tells us to round both in the same direction, they yield the same result.
  3. If n’ < n’’ and the tie-breaking scheme tells us to round n’ down and n’’ up, then |round(n’) - n| < |round(n’’) - n| because rounding n’ is strictly within half the rounding precision while rounding n’’ isn’t.
Photo by Ashkan Forouzani on Unsplash

What if, instead, “round half down” was used as the breaking scheme for n’’ and “round half up” was used for n’?

  1. If both were rounded in the same direction, they yield the same result.
  2. It’s impossible for n’’ to be rounded up while n’ is rounded down, since n’’ - 1 ≤ n’.
  3. If n’’ was rounded down and n’ was rounded up, then n’ = n’’ because it’s given that n’’ ≥ n’. Hence |round(n’) — n| < |round(n’’) — n|.

If rounding half down was used more than once in the progressive rounding process, then the above proof can be repeated each time it occurs, showing that progressive rounding always causes greater error. The extension of this claim to negative numbers can be completed in a similar manner by dealing with absolute values.

(4) Quirky Rounding: Medium’s View Counter

An interesting case of rounding is Medium’s View Counter.

The View Counter

We know 11 views constitutes approximately 14% of the views, and a quick recovery tells us that the total number of views is 11 / 0.14 = 78.57. This is rounded to the nearest whole number, which is 79. The question is, does this rounding always work?

First of all, we know that the precision is limited; i.e., it is no longer guaranteed for more than 100 views. A simple example demonstrates this:

If we have a total of 101 views with 11 of them being from External Referrals, then that is approximately 11% of views.

However, calculation gives 11 / 0.11 = 100, causing us to lose one view!

I guess we wouldn’t care too much about losing one view if we already had 100 views. But what if we didn’t have 100 views? Will we still lose/gain views out of nowhere?

Unfortunately, for the standard “round half up”, the answer is yes.

If we have 27 views and 5 of them are External Referrals, then that is approximately 19% of views, and 5 / 0.19 = 26.

However, we’ll show that some rounding technique exists in these situations. Let the total number of views be T ≤ 100, with kT views from external referrals.

First of all, given any “decent” rounding function, round(100k / T) will always be injective for a fixed T; i.e., if round(100k / T) = round(100k’ / T), then k = k’. This is obviously true for T = 100, and for T < 100 it is still true because 100(k + 1) / T = 100k / T + 100 / T > 100k / T + 1. Since a good rounding function maintains half-rounding precision, two numbers with difference greater than 1 cannot be rounded to the same number.

Next, round(100k / round(100k / T)), the function which recovers its original value, should always equal T. However, we already know that this isn’t always true; hence we won’t put any more effort into proving it.

We’ll compute the possible values by exhaustion:

public class Main {
public static void main(String[] args) {
for (int T = 1; T <= 100; T++) {
boolean flag = false;
for (int k = 1; k <= T; k++) {
if (100 * k / Math.round(100 * k / T) == T) {
continue;
} else {
flag = true;
break;
}
}
if (flag == true) {
System.out.println(T + " is bad!");
} else {
System.out.println(T + " is good!");
}
}
}
}

Exhaustive enumeration gives the following “good” values for which rounding half up works:

1–12, 14, 16, 20, 25, 33, 50, 100.

Honestly, not that many.

Abstract Rounding Scheme

On the other hand, is there some rounding function that we just cannot find? Let’s attempt to show that a rounding function exists without actually finding out what it is.

If we could prove that the function 100k / round(100k / T) is injective for a fixed k (taking T as our variable), then a rounding function theoretically exists; in such cases, although it may not output T, it outputs a distinct value for different T, so it basically changes the labelling of the numbers without changing their properties.

Under the standard definition of rounding, as long as it is a function which uniquely maps each number to a corresponding number with lower precision while preserving order, then it is a rounding function. We’re no longer considering practicality here; a hypothetical rounding function could round 0.5 to -1 and 0.55 to 1 because it preserves order, reduces precision and rounds to uniquely distinct values. We will denote this arbitrary function by abround(k, N) where k is fixed (hence it will be neglected) and N is the number being rounded.

Since T + 1 > T, the existence of this new rounding function requires the order-preserving property abround(100k / round(100k / (T + 1))) > abround(100k / round(100k / T)). We just need to show that 100k / round(100k / (T + 1)) > 100k / round(100k / T). Since we already used an abstract rounding function, we construct another function fround(k, N). Since we desire fround(100k / (T + 1)) < fround(100k / T) and the original expression satisfies 100k / (T + 1) < 100k / T, fround() exists.

Finally, combining the things we’ve just done, this will allow us to obtain a construction abround(100k / fround(100k / T)) = T, as desired.

In reality, we might’ve proved the existence of a rounding scheme without all this math. Can you think of how?

Concluding Remarks

You’ve done plenty of mathematics through the “simple” task of rounding numbers. In case you’re interested, here’s some related math:

  1. Mathematical induction
  2. Linear maps and dimensional theories of vector spaces
  3. Algebraic number theory
  4. Probability distributions

That’s it. Happy Mathing!!!

--

--