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 Answers 2


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

  • $\begingroup$ can you please explain your answer using fractions? maybe the difference can be shown using only fractions for bits 3,4,5 instead of using the entire number for comparison? $\endgroup$ May 22, 2016 at 11:22
  • $\begingroup$ @Maximus: One does not need fractions. Simply count the number of leading zeros in the difference. $0.00011$ is smaller than $0.00101$ in any base. $\endgroup$
    – ccorn
    May 22, 2016 at 11:30
  • $\begingroup$ @ccorn, well, I want to understand it using fractions) But it seems that nobody wants to explain that :( $\endgroup$ May 22, 2016 at 11:51
  • $\begingroup$ @Maximus: From the question it seems that you can convert to fractions yourself. (In fact, veryfing the writings of others takes longer than just doing the calculations yourself, so brevity saves everybody's time.) And regardless of how the numbers are represented, it's a round-to-nearest approach. That's what the answer is about. $\endgroup$
    – ccorn
    May 22, 2016 at 12:29

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.

  • $\begingroup$ thanks for you efforts, I was probably after this kind of explanation, but it also helped that you mentioned 0.5000 which I've never considered before. If you have time, would you please answer questions I asked in the comments under the answer I linked? $\endgroup$ May 22, 2016 at 14:19

You must log in to answer this question.

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