Binary shift
Apply the following shift to this binary number: 0
Binary shifts move all bits left or right by a specified number of positions.
- Left shift: Multiplies the number by 2 for each position shifted
- Right shift: Divides the number by 2 for each position shifted (rounds down)
Example: Shift 00001100 (12 in denary) left by 2 places:
Original: 00001100 (12)
Shift left 2: 00110000 (48)
Result: 12 × 2 × 2 = 48Binary shifts are a quick way to multiply or divide binary numbers by powers of 2.
Left Shift
Moving bits to the left multiplies the number by 2 for each position:
- Each bit moves one position to the left
- Zeros are added on the right
- Bits that shift off the left end are lost
- Left shift by n positions = multiply by 2n
Right Shift
Moving bits to the right divides the number by 2 for each position:
- Each bit moves one position to the right
- Zeros are added on the left
- Bits that shift off the right end are lost (rounds down)
- Right shift by n positions = divide by 2n
Examples
Left shift: 00000101 (5) left by 3 places
00000101 → 00101000
5 × 2³ = 5 × 8 = 40 Right shift: 01100100 (100) right by 2 places
01100100 → 00011001
100 ÷ 2² = 100 ÷ 4 = 25 Important: Shifting can cause overflow (left shift) or loss of precision (right shift) if bits are pushed off the ends.
References: