1
$\begingroup$

What's the correct way to round, or estimate, a number to a specified precision?

Starting with wikipedia:

Rounding a number twice in succession to different precisions, with the latter precision being coarser, is not guaranteed to give the same result as rounding once to the final precision except in the case of directed rounding. For instance rounding 9.46 to one decimal gives 9.5, and then 10 when rounding to integer using rounding half to even, but would give 9 when rounded to integer directly.

http://en.wikipedia.org/wiki/Rounding#Double_rounding

That just makes no sense to me. What's the justification for different results? If 9.46 rounds to 9.5 why doesn't it then round to 10?

edit

I didn't ask the question correctly. The question, I think and hope I mean to ask, is why, or how, perhaps, double rounding and regular rounding can give different results (using half to even), and I suppose the answer is that there are different rounding algorithms which give different results.

I was thinking there should be one, correct answer as to what 9.46 rounded to the nearest integer rounds to. Double rounding, apparently, gives ten while "regular" rounding gives 9. Guess it just seems odd or weird to me to not double round.

$\endgroup$
16
  • 1
    $\begingroup$ $9.46$ is closer to $9$ than to $10$. Therefore, rounding it directly to an integer produces $9$. $\endgroup$ Commented Dec 9, 2013 at 13:27
  • 7
    $\begingroup$ $$9.46 - 9 = \frac{23}{50} < \frac{27}{50} = 10 - 9.46$$ $\endgroup$ Commented Dec 9, 2013 at 13:29
  • 3
    $\begingroup$ ahah I didn't realize the notion of "distance" over the Real numbers was so controversial $\endgroup$
    – Ant
    Commented Dec 9, 2013 at 13:31
  • 2
    $\begingroup$ The rounded $9.5$ is right-smack in the middle between $9$ and $10$, not closer to $10$. Whether it gets rounded to $9$ or to $10$ depends on the used tie-breaking rule. But when rounding directly, we consider only the two closest integers to the number, and $9.5$ isn't one of them. So we look at $9$ and $10$ and see whether one of the two is closer, then that's the result of rounding, or both are equally far away, and then we use the tie-breaking rule. $\endgroup$ Commented Dec 9, 2013 at 13:39
  • 4
    $\begingroup$ @Thufir Wot? No. Wikipedia and I say when you directly round to an integer, then $9.46$ is rounded to $9$. When you first round to an intermediate precision, all bets are off. $\endgroup$ Commented Dec 9, 2013 at 13:40

3 Answers 3

6
$\begingroup$

That's exactly what Wikipedia is saying:

As you note: If you round first to one decimal place, then $9.46$ first rounds to $9.5$. If you round then to the nearest integer, it rounds to $10$.

But if you round $9.46$ directly to the nearest integer, then since $0.46 < 0.5$, $9.46$ rounds to $9$.

The point of the Wikipedia article is to show that rounding successively, first to one decimal place, and then to the nearest integer, can yield different results than rounding directly to the nearest integer, in this case.


Another way to look at why, when rounding directly from $9.46$ to the nearest integer results in $9$, note the following:

The "distance" of $9.46$ from $10$ is $.54$. The "distance" of $9.46$ from $9$ is only $.46$. So $9.46$ is closer to $9$ than it is to $10$. So, when rounding directly to the nearest integer, $9.46$ rounds to $9$.

$\endgroup$
9
  • $\begingroup$ I must be asking the wrong question. Why? 9.46999999999 seems closer to ten than nine to me... $\endgroup$
    – Thufir
    Commented Dec 9, 2013 at 13:29
  • 2
    $\begingroup$ No, it is not. $0.4699999999 < 0.5000000000$, so $9.46999999999$ rounds to $9.0 = 9$. Note that the distance of $9.46$ from $10$ is $.54$. The distance of $9.46$ from $9$ is only $.46$. So $9.46$ is closer to $9$ than it is to $10$. $\endgroup$
    – amWhy
    Commented Dec 9, 2013 at 13:31
  • $\begingroup$ ok, your edit is interesting. I remain unconvinced yet because the estimate puts it closer to 9.5, which, by this convention, puts it closer...hmm. $\endgroup$
    – Thufir
    Commented Dec 9, 2013 at 13:38
  • 2
    $\begingroup$ But the point of rounding directly to the nearest integer is to round everything that follows from the decimal point leftward to the nearest integer. $9.5$ is not an integer. Remember, Wikipedia is pointing out that, yes, if you first round to the nearest tenth of an integer, then $9.46$ rounds to $9.5$. But not so when rounding directly to the nearest whole integer. Rounding to different levels of precision, successively, can and often does result in a different final result. Now, if you're simply trolling, I won't continue the conversation. $\endgroup$
    – amWhy
    Commented Dec 9, 2013 at 13:45
  • 1
    $\begingroup$ Thufir: Is this making a little more sense, as it relates to the Wikipedia article? The more times one rounds a number (first to tenths, then to whole integer), the more imprecision enters the picture, since rounding gives an approximation. So approximating an approximation can be less accurate than making only one approximation. $\endgroup$
    – amWhy
    Commented Dec 9, 2013 at 14:08
3
$\begingroup$

Another approach is to think of "rounded numbers" as a different sort of object than real numbers. So $9.5(1\text{dp})$ is not the same as $9.5$, it's not quite a number at all.

On this understanding, the rules for rounding off "rounded numbers" have a hole in them. If $x = 9.4 (1\text{dp})$ then $x = 9 (\text{nearest int.})$. If $x =9.6 (1\text{dp})$ then $x = 10 (\text{nearest int.})$. But if $x = 9.5 (1\text{dp})$, then we can't know whether whatever real number $x$ is would be closer to $9$ or to $10$, so the nearest integer to $x$ is undefined. Double rounding isn't always allowed.

Using set notation, we would define $9.5(1\text{dp}) := \{y \in \mathbb{R}: 9.45 \leq y < 9.55\}$. Conventionally, $\mathbb{R}$ means the set of real, unrounded numbers.

Then in the formula $9.46 = 9.5(1\text{dp})$ the equals sign is actually standing in for set membership $\in$. The rules for arithmetic with "rounded numbers" are just that a formula is true exactly if it would be true for every real number in the set. So sometimes we get undefined results.

For example $2 \times 9.46(2\text{dp}) = 18.9(1\text{dp})$, but $2 \times 9.46(2\text{dp})$ is undefined to 2 d.p., because depending on what the real number chosen from the set was, we might get either $18.92 (2\text{dp})$ or $18.93 (2\text{dp})$. This is why in practical calculations you always need to measure, where possible, to more digits of precision than you need in your answer.

$\endgroup$
1
  • $\begingroup$ for x=9.5(1dp), I appreciate the important point that it's not really a number, at least not like 9.5 is. I'm unsure what it is if not a true number, but that seems significant. Your further point, that from this understanding, there's a hole in double (or let's say repeated) rounding, definitely has legs. On the minor point that we can't know whether x=9.5(1dp) is closer to 9 or 10, yes, but we're going with rounding up from half, which I think Wikipedia calls "half to even." Interesting answer! $\endgroup$
    – Thufir
    Commented Dec 9, 2013 at 16:04
2
$\begingroup$

To summarize info from comments and answers and provide a slightly different twist ...

Consider that you are on an island located at 9.46 and you are asked to jump to a nearest island located at each tenth (0.1). You look around and see two islands around you. One at 9.4, one at 9.5. One closest to you is at 9.5, so you jump there.

Next, you are asked to jump to the closest island located at a whole number. You look around and see that there are two, one at 9, one at 10 and both are equally close. Convention states for you to jump to one that is higher in value. There is a 50% chance that this convention is wrong and it happens to be wrong here.

Convention did not take into consideration the fact that you just came from a different island in a specific direction. Convention did not take into consideration the previous direction of rounding, and it sent you in the wrong direction.

What we see here is

  • Convention does not take into consideration direction of the previous rounding
  • Convention is 50% wrong in the case of rounding on a one-dimensional number line
  • Convention happened to be wrong here.

How to mitigate

If you want to be more precise, i.e. if you double-round numbers in some algorithm, then implement directional rounding. Remember direction of the previous rounding and when you come to the 50/50 decision, make you rounding direction to go in the opposite direction from the previous one. i.e. first jump from 9.46 to 9.5 was in the positive direction. Next jump should be from 9.5 to 9, in the negative direction.

Alternatively, store more significant digits for precision and round once, whenever needed.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .