Why always round down if next bit is zero

514 Views Asked by At

I'm trying to understand rounding of binary numbers using number representation as a sum of fractions. So suppose I have a number in binary: $$ 0.11011 = 0 + 1\times\frac{1}{2} + 1\times\frac{1}{4} + 0\times\frac{1}{8} + 1\times\frac{1}{16} + 1\times\frac{1}{32} $$

I want to round it to 2 significant digits after the radix point. I've read that:

If bit 3 is 0, round down

Can someone please explain me why it's so using fractions I showed in my example?

2

There are 2 best solutions below

1
On BEST ANSWER

I will use a decimal analogy here.

Let's consider the case of rounding $x=123.45$ to the nearest integer $X$. The round-to-nearest approach requires that the rounded result $X$ is as close to the non-rounded number $x$ as possible. This means $|X-x|\leq\frac{1}{2}=0.5$. That requirement translates to:

  • Round downwards if the leftmost digit of the to-be-rounded-away string is in $\{0,\ldots,4\}$;
  • Round upwards if the leftmost digit of the to-be-rounded-away string is in $\{6,\ldots,9\}$;
  • Also round upwards if it is $5$ and the following digits are not all zero.
  • If the to-be-rounded-away string is $.5000\ldots$ (only zeros following), then both rounding directions result in the same distance. That's the tie case. It is usually resolved with some auxiliary rule. The simplest version is to round up. This allows us to decide on the rounding direction by looking at the leftmost to-be-rounded-away digit only: If it is $5,\ldots,9$, round up, else round down.

In our example, $X=123$ (rounded down). If we were to round sequentially, one digit at a time, first to $123.5$, then to $124$, the result would not be the nearest possible to the unrounded value $x$.

The critical digit is $5$ because we are dealing with base $10$ here: $\frac{1}{2}=\frac{5}{10}$. For base $2$, the critical digit is $1$, therefore the analogous rule for binary representations is to round up if the leftmost to-be-rounded-away bit is $1$ (and higher, but there are no higher digits in the binary system), else to round down.

4
On

Because dropping $0.11011$ is closer to $0.11$ (difference $0.00011$) than to $1.00$ (difference $0.00101$).