Binary shifts

If a binary number is shifted to the left this is equivalent to multiplying the number by 2 for each shift to the left.

For example: if we shift


Two places to the left we get the binary number:

Notice how we moved the digits to the left and filled the gaps in the 8-bit binary number with zeros as we shifted left.

The original binary number has a value of 15 (i.e. 1+2+4+8 = 15); the number after shifting two places to the left has the value 60 (i.e. 32+16+8+4 = 60). It is multiplied by 4, or 22.

Shifting binary numbers to the right has the opposite effect i.e each shift to the right has the effect of dividing by 2.

Multiplication and Division by powers of 2

This gives an easy way to multiply and divide binary numbers by the powers of two.

This is the equivalent of shifting a decimal number right or left - for example shifting 44000 right 1 place = 4400 (it divides the number by 10). Shifting left multiplies the number by 10.