[Math] why shifting left 1 bit is the same as multiply the number by 2

binary

I have recently faced a problem .The problem is here.We know that if we represent
a decimal number in binary and move left all the bits by one. The left most bit is lost! and at the rightmost, a zero is added.

The above bit operation actually produce a number that is result of multiplication of the given number and 2.

For example,
$0001001101110010 ⇒ a = 4978(16 bit)$

—————- << 1 (SHIFT LEFT the bits by one bit)

$0010011011100100 ⇒ 9956$

My question is that why it happens? Can anyone explain what the reason behind it?

Best Answer

There is a direct analogous when you work with base $10$.

Take the number $3$ in base $10$. Shift it left: you get $30$, which is $3 \cdot 10$ (and the factor $10$ appears because you are working with base $10$).

The same applies to base $2$. Shifting left is the same as multiplying by $2$.

This comes from the use of positional notation to denote numbers (https://en.wikipedia.org/wiki/Positional_notation).

In base $b$ ($b>1$) the second digit from the right counts $b$ times more than the first digit from the right, the third from the right counts $b$ times more than the second from the right (or $b^2$ times more than the first from the right), and so on.

When you write a number like this

$$ a_n a_{n-1} \dots a_2 a_1 a_0 $$

(in base $b$), what you actually mean is the following

$$ a_n \cdot b^n + a_{n-1} \cdot b^{n-1} + \dots + a_2 \cdot b^2 + a_1 \cdot b^1 + a_0 \cdot b^0.$$

With this in mind one can show that the two operations of shifting left and multiplying by $b$ are actually the same:

$$ a_n a_{n-1} \dots a_2 a_1 a_0 0 = \\ = a_n \cdot b^{n+1} + a_{n-1} \cdot b^{n} + \dots + a_2 \cdot b^3 + a_1 \cdot b^2 + a_0 \cdot b^1 + 0 \cdot b^0 =\\= b \cdot \left(a_n \cdot b^n + a_{n-1} \cdot b^{n-1} + \dots + a_2 \cdot b^2 + a_1 \cdot b^1 + a_0 \cdot b^0 \right) =\\= b \cdot (a_n a_{n-1} \dots a_2 a_1 a_0). $$