A mathematical proof for shifting a number left

413 Views Asked by At

I need a full mathematical proof for the fact that when you shift a (let's say) binary number to the left (adding a zero to the right) it is like multiplying it by two (or any other base).

1

There are 1 best solutions below

0
On

Binary numbers can be represented as $$a_0 + a_1(2^1) + a_2(2^2) + \dots + a_n(2^n)$$ where the $a_n$ are the binary digits (either $0$ or $1$). Then, if we "shift" each digit to the left and add a zero we get $$0 + a_0(2^1) + a_1(2^2) + \dots + a_n(2^{n+1}) = 2(a_0 + a_1(2^1) + a_2(2^2) + \dots + a_n(2^n))$$ This wll hold for any base, where instead of powers of $2$ you have powers of whatever base you're in.