Data Representation · 4 question types
Past paper frequency (2018 to 2024)
This topic accounts for approximately 12% of your exam marks.
Binary/hex conversion and binary arithmetic appear in every Paper 1. Consistently 8 to 15 marks.
A logical binary shift is the operation of moving every bit of a binary number a fixed number of places to the left or to the right. Bits that fall off the end of the register are lost; the vacated positions are filled with 0s.
A logical left shift by 1 moves every bit one position to the left. The leftmost bit falls off; a 0 is filled in on the right.
The effect on the value is to multiply by 2 (provided no 1-bit falls off the end):
Example — Apply a logical left shift of 1 to the 8-bit binary number representing 40.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
After shifting every bit one place to the left:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
40 × 2 = 80. ✓
A logical right shift by 1 moves every bit one position to the right. The rightmost bit falls off; a 0 is filled in on the left.
The effect on the value is to divide by 2 (integer division, with no remainder):
Example — Apply a logical right shift of 2 to the 8-bit binary number representing 200.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
After shifting every bit two places to the right:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
200 ÷ 4 = 50. ✓
If a 1 is shifted off either end of the register, the simple ×2ⁿ or ÷2ⁿ rule no longer holds and information is lost: