Data Representation & Number Systems
1. Why Data Representation is Needed
A digital computer is built from two-state devices — a transistor is either on (1) or off (0). It therefore understands only binary, and every kind of information must be encoded as a pattern of bits: numbers, characters, images, audio, video and even the instructions of a program. Data representation is the set of rules for that encoding.
| Data type | How it is represented | Unit of measurement |
|---|---|---|
| Integers | Positional binary, signed or unsigned | bit / byte |
| Real numbers | Floating point (IEEE-754: sign, exponent, mantissa) | bit |
| Characters | ASCII (8-bit), Unicode (8/16/32-bit), BCD for digits | byte |
| Images | Grid of pixels, each with a colour code (colour depth) | pixels × bits per pixel |
| Audio | Amplitude sampled at fixed intervals | samples/s (Hz) × bit depth |
| Video | Sequence of frames + compression | frames/s + bit rate |
| Instructions | Opcode + operand fields | bits per instruction word |
2. Positional Number Systems
In a positional system, the value of a digit depends on its position. With radix (base) and digits :
Two ideas follow directly from this: any base works, and the base tells you how many symbols are needed.
3. The Four Systems Used in Computing
| System | Base (radix) | Digits allowed | Suffix examples | Why used |
|---|---|---|---|---|
| Binary | 2 | 0, 1 | or 1011B | Native machine language; simple, reliable two-state circuits |
| Octal | 8 | 0-7 | or 653O | Compact shorthand for binary — 1 octal digit = 3 bits |
| Decimal | 10 | 0-9 | 987 or 987D | Human everyday arithmetic |
| Hexadecimal | 16 | 0-9, A-F (A=10 … F=15) | or 2AFH | Compact shorthand — 1 hex digit = 4 bits; used for addresses, memory dumps, MAC addresses |
| BCD | 10 (as 4-bit groups) | 0000-1001 | 25 → 0010 0101 | Exact decimal arithmetic (calculators, banking); wastes 6 of 16 codes |
| Gray code | 2 (reflected) | 0, 1 | 3 → 0010 | Only one bit changes between consecutive codes; used in encoders, K-maps |
4. Counting in All Four Systems
| Decimal | Binary (4-bit) | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
5. Why Binary is Used in Computers
- Only two stable states (saturated / cut-off transistor, charged / discharged capacitor) — highly reliable and noise-resistant.
- Simple circuits — one circuit (adder) handles all arithmetic; Boolean logic maps directly onto gates.
- Cheap and easy to build with switches, relays, magnetic and optical media.
- Arithmetic and error-control (parity, checksums) are simplest in base 2.
Octal and hexadecimal exist purely as human-friendly shorthands for binary: one digit condenses 3 or 4 bits, so long addresses become readable.
6. How Many Bits Do You Need?
To represent distinct values you need bits where
| Values to represent | Bits needed | Example |
|---|---|---|
| 10 digits | 4 | BCD |
| 26 letters | 5 () | one alphabet |
| 128 ASCII characters | 7 (stored in 8) | ASCII |
| 65,536 characters | 16 | Unicode BMP |
| 256 colours | 1 byte per pixel | GIF palette image |
7. Exam Points
- Why are octal and hexadecimal used in computer work? — 3-5 marks, very frequent.
- Explain the positional number system with the general formula — 5 marks.
- Compare binary, octal, decimal and hexadecimal with digits and base — 5 marks.
- What is BCD? Why is it used in calculators? — 3 marks.
- How many bits are needed to represent n characters/values? — 3 marks numerical.
- How are pictures, sound and characters represented in a computer? — 5 marks.