A binary shift moves all the bits in a binary number left or right by a specified number of places. Bits shifted beyond the edge of the register are lost; vacant positions are filled with 0s.
Binary shifts are used by CPUs for fast multiplication and division by powers of 2.
A left shift by 1 place multiplies the value by 2. A left shift by n places multiplies by 2ⁿ.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| Before (12) | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| After shift left 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
Result: 00011000 = 24. 12 × 2 = 24 ✓
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| Before (3) | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| After shift left 3 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
Result: 00011000 = 24. 3 × 2³ = 3 × 8 = 24 ✓
A right shift by 1 place divides the value by 2 (integer division, remainder lost). A right shift by n places divides by 2ⁿ.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| Before (24) | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| After shift right 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
Result: 00001100 = 12. 24 ÷ 2 = 12 ✓
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| Before (28) | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| After shift right 2 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
Result: 00000111 = 7. 28 ÷ 4 = 7 ✓
| Shift type | Direction | Effect on value | Bits shifted out | Fill with |
|---|---|---|---|---|
| Left shift ×1 | ← left | × 2 | MSB lost | 0 at LSB |
| Left shift ×n | ← left n | × 2ⁿ | n MSBs lost | 0s at LSB |
| Right shift ×1 | → right | ÷ 2 | LSB lost | 0 at MSB |
| Right shift ×n | → right n | ÷ 2ⁿ | n LSBs lost | 0s at MSB |
Bit shifting is a much faster CPU operation than conventional multiplication or division circuits. It is used in:
Bits shifted beyond the register boundary are permanently lost. If a 1-bit is shifted out during a left shift, the result is smaller than expected (similar in concept to overflow). If a 1-bit is shifted out during a right shift, the result is an integer division — any remainder is discarded.
For example: right shift 00000111 (7) by 1 = 00000011 (3), not 3.5. The 1 shifted out from the LSB is lost.
8 questions · 18 marks · Show bit patterns before and after
| Term | Definition |
|---|
10 questions · 10 marks · 10 minutes