Data Representation
1. What is Data Representation?
Definition: Data representation refers to the form in which data is stored, processed and transmitted inside a computer.
Computers only understand binary (only 0s and 1s) — the “computer-understandable language”. A group of 8 bits = 1 byte.
2. Prefixes — Binary vs Decimal
You already know prefixes from physics (kilo, milli, centi, nano, pico…). Data has its own units too. At AS/A Level the data prefixes are split into two families:
| Binary prefixes | Decimal prefixes | |
|---|---|---|
| 1st | Kibibyte | Kilobyte |
| 2nd | Mebibyte | Megabyte |
| 3rd | Gibibyte | Gigabyte |
| 4th | Tebibyte | Terabyte |
| factor | × / ÷ 1024 | × / ÷ 1000 |
Why two families? (the 1024 / 1000 confusion)
In you were allowed to use either 1024 or 1000 when converting units (1000 was popular — no calculator, easy to multiply). That caused confusion: which one was used? — and it makes a big difference, especially for large numbers:
So the units were given separate names: binary prefixes → 1024, decimal prefixes → 1000.
Basic unit facts (write these down)
- Smallest unit of data = bit (a single 0 or a single 1)
- One byte contains 8 bits
- 4 bits are known as a nibble (half a byte)
- 1 kilobyte = 1000 bytes | 1 kibibyte = 1024 bytes
- 1 megabyte = 1000 kilobytes | 1 mebibyte = 1024 kibibytes
- Same pattern for giga/gibi and tera/tebi (gibi = 1024 mebi, etc.)
Match: 8 bits · 8000 bits · 1000 kilobytes · 1024 mebibytes · 8192 bits → to 1 kibibyte / gigabyte / byte / kilobyte / gibibyte / megabyte / mebibyte.
Trick: if the value is in bits, first ÷ 8 to get bytes. Then check: factor 1000 or 1024?
| Binary value | Working | Equals |
|---|---|---|
| 8 bits | 8 ÷ 8 = 1 byte | 1 byte |
| 8000 bits | ÷ 8 = 1000 bytes (factor 1000) | 1 kilobyte |
| 1000 kilobytes | ÷ 1000 | 1 megabyte |
| 1024 mebibytes | ÷ 1024 | 1 gibibyte |
| 8192 bits | ÷ 8 = 1024 bytes (factor 1024) | 1 kibibyte |
Careful: 8192 bits ≠ 1024 bits — convert bits → bytes first (÷ 8). “1 gigabyte” and “1 mebibyte” are the unused decoys.
3. Number Systems & Conversions
- Binary — base 2 (only 0, 1) — the computer’s own language
- Denary (decimal) — base 10 — normal maths numbers: 15, 16, 17…
- Hexadecimal — base 16 (0–9 then A–F)
Base = just the way of representing a number. The exam gives you a number in one system and asks you to convert to another: binary→denary, denary→binary, binary→hex, hex→binary, denary→hex… Only these appear in the syllabus.
Case 1 — Denary → Binary
Q: Convert 65 into 8-bit binary. (8-bit = 1 byte)
- Step 1: Write down the memorised list.
- Step 2: Place 1 on specific places so the total is the same as the denary number given. Every other place gets 0.
Ans: 01000001
How to pick the 1s: go left → right; put a 1 only if that place value still “fits” in what is left.
Convert the denary integer 55 into 8-bit binary.
Case 2 — Binary → Denary
Q: Convert 01000001 to denary. (Same number as before, reversed.)
- Step 1: Write the memorised list under the binary number (right-aligned).
- Step 2: Add only the numbers that have a 1 above them.
Convert the 8-bit binary integer 01001101 into denary.
Case 3 — Binary → Hexadecimal
| Value box | |
|---|---|
| A = 10 | D = 13 |
| B = 11 | E = 14 |
| C = 12 | F = 15 |
Q: Convert 11011001 into hexadecimal.
- Step 1: From the right, divide the binary value into groups of four (missing bits → add 0s on the left). Hex ⇒ always groups of 4!
- Step 2: Write the memorised list (8 4 2 1) separately for each group.
- Step 3: Add the numbers with 1. If the total is greater than 9 → use the value box.
General purpose register X holds 1111 0010 (unsigned binary integer).
Case 4 — Denary → Hexadecimal
Q: Convert 195 to hexadecimal.
- Step 1: First convert the denary number into binary.
- Step 2: Repeat the steps of Case 3 (groups of 4 → 8 4 2 1 → value box).
(There is a direct method but it is long — we always go via binary: one extra step, much easier.)
Convert the hexadecimal number 4E into denary. (board: E = 14)
Tip: hex → binary is the “reverse working” of Case 3. A 3-digit hex like 4EF has three 4-bit groups. Each hex digit ↔ one nibble.
(Uses of hexadecimal — MAC addresses, colour codes — were to be dictated separately by sir; not on the board.)
4. Binary Coded Decimal (BCD)
Definition: BCD uses a 4-bit code to represent each denary digit. Another way of representing data.
Any number is made of digits 0–9. BCD gives every single digit its own 4-bit binary code (use 8 4 2 1 and put 1s to make the digit).
| Digit | BCD | Digit | BCD |
|---|---|---|---|
| 0 | 0000 | 5 | 0101 |
| 1 | 0001 | 6 | 0110 |
| 2 | 0010 | 7 | 0111 |
| 3 | 0011 | 8 | 1000 |
| 4 | 0100 | 9 | 1001 |
Case 1 — Denary → BCD
Q: Convert 54 into BCD.
Step 1: convert each digit into BCD format, then write them side by side.
Convert the denary integer 653 into BCD.
Leave a small gap between the groups so the examiner isn’t confused.
Case 2 — BCD → Denary
Q: Convert 0101 0100 (BCD) to denary.
- Step 1: Make groups of 4 (from the right).
- Step 2: Write 8 4 2 1 on each group and add the numbers with 1.
Convert the BCD number 10000011 into denary.
Groups are made from the right side, always.
BCD — theory questions (wording to copy)
Q: Describe how denary integers larger than 9 can be converted into BCD. Give an example in your answer.
Each denary digit is written as a 4-bit binary number.
Example: 46 = 0100 0110
Q: Describe how an 8-bit BCD can be converted into a denary integer. Give an example in your answer.
Binary number is split into groups of 4 bits (starting from the right). Each group of 4 bits is converted to a denary digit.
Example: 0011 0111 = 37
Q: Identify practical applications where BCD is used.
Any scenario where a single digit needs to be transmitted / displayed. e.g. calculator / digital clock
Also: timer, traffic signal, ATM — anything that shows single digits.
5. Binary Addition
Each column gives a Sum (S) and a Carry (C). (The proper working — logic gates / “adders” — is in A2; for now just learn these 5 results.)
| Adding | S | C |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 | 1 | 1 |
Practice questions (basic)
Green 1s on top = carries. Faded 0s = padding added to fill the empty places. (Check ①: 2+3 = 5 = 101 ✓)
The amount of green in binary is 00100011. The denary number 15 is added to it. Add 15 to 00100011 and give the answer in binary — show working.
First convert 15 to binary (you need binary to add): 8+4+2+1 → 00001111. Then add.
Perform the binary addition. Show your working.
6. Negative Numbers — Two’s Complement
Only two cases come up: (1) given a negative denary → write its binary form; (2) given a binary (two’s complement) → find the denary value. (Sometimes then hex — you already know that.)
Case 1 — Negative denary → binary
Q: Convert −125 to binary form.
- Step 1: Ignore the negative sign and convert +125 to binary.
- Step 2: Apply two’s complement: ① one’s complement = inverse (1→0, 0→1) ② then add binary 1.
Answer: 10000011
Convert the denary number −194 into 12-bit two’s complement.
Only ~1 in 10 students get this right!
First write +194 in 12 bits (pad zeros on the left before inverting), then apply two’s complement.
Answer: 1111 0011 1110
Case 2 — Binary (two’s complement) → Denary
Register H holds 1 1 0 0 0 0 0 1.
(i) H unsigned → denary: add the place values with 1.
(ii) H → hexadecimal: groups of 4 from the right.
(iii) H is a two’s complement integer → denary. First bit is 1 → negative, so apply two’s complement to find the size:
(iv) State why register H does not currently contain a BCD.
The first 4 bits would be 12 (1100) which is greater than 9 (which is not valid for BCD).
Sir’s answer wording: “first 4 bits = 12, greater than 9, not valid for BCD”. (Negative numbers aren’t the reason — e.g. 10000011 is valid BCD = 83.)
X = 1 1 0 0 0 0 0 1: (i) unsigned → denary 193 · (ii) hexadecimal C1 · (iii) two’s complement → denary −63 (same value as register H above)
Express −17 in 8-bit two’s complement form.
17 = 00010001 → inverse 11101110 → +1 → 11101111
7. Binary Subtraction
Subtracting is the same as adding a negative number:
Hexadecimal 23 in two’s complement representation is 00100011. The denary number 10 needs to be subtracted from this value. Give your answer in binary and show your working.
23 − 10 ≡ 23 + (−10). Show every step — 3 marks!
Answer (in binary): 00011001
00100011 − 20 → 20 = 00010100 → −20 = 11101100 → 00100011 + 11101100 = (1) 00001111 (overflow bit dropped).
8. Concept of Overflow
Idea: more bits to store, but less space. A memory location holds a fixed number of bits — if the answer needs more, the extra bit(s) don’t fit → error called overflow. The data isn’t fully saved, so accuracy can suffer.
OS = 64 bit means each memory location stores 64 bits; a 65-bit answer overflows by 1 bit. (Don’t confuse 32-/64-bit OS labels — they just state how many bits per location.) Here we use 8-bit locations: a 9th bit = overflow bit; a 10-bit answer → the last two bits overflow.
Q: State how an overflow can occur when adding two binary integers.
The result is a larger number than can be stored in the given number of bits.
9. ASCII, Extended ASCII & Unicode
Basic concept: numbers are easy to convert to binary. e.g. 67:
But what about A, B, [ ] or Enter, Backspace, Delete…? The computer only understands 0s and 1s, and there was no way to represent alphabets / characters / symbols. So a standard code was set: every character gets its own denary value, which is stored in binary.
| Character | Denary code | 8-bit binary |
|---|---|---|
| A | 65 | 01000001 |
| B | 66 | 01000010 |
| [ | 91 | 01011011 |
| ] | 93 | 01011101 |
The board left A, B and [ ] as “?” — filled in here using A = 65 and the ASCII table (B = 65 + 1).
Table columns: Dec / Hex / Oct / Char — e.g. 49 = hex 31 = ‘1’; 65 = hex 41 = ‘A’; 97 = hex 61 = ‘a’; 127 = Delete.
ASCII
- 7 bits per code
- 128 characters can be represented (values 0–127, one byte used)
- Full form: American Standard Code for Information Interchange (no need to memorise)
Why 128? 64+32+16+8+4+2+1 = 127; add 1 for the all-zero code → 128 characters. (Same trick: 1+2+…+128 = 255, +1 = 256.)
Extended ASCII
- 8 bits (place values 128 … 1)
- ASCII codes were 7 bits long but then it was extended to have a bit length of 8
- 256 characters can be represented
Unicode
Problem: Arabic, Greek, Hindi, Urdu … — every language has its own characters and 256 is far too few → no representation.
Solution — Unicode: uses 16, 24 or 32 bits per code, so most characters of other languages can be represented.
(Extra concept from the lecture — sets & Venn idea: B ⊃ A means B contains all of A’s values. Sir said not to put it in the notes, but it explains “superset”.)
Comparison table
| ASCII | Extended ASCII | Unicode | |
|---|---|---|---|
| Bits | 7 | 8 | 16, 24, 32 |
| Characters | 128 | 256 | most of the world’s languages |
| Range / note | 0–127, same on every system | 128–255 coded differently on different systems | superset of ASCII |
Q: What are the disadvantages of using ASCII code?
- Only 128 characters can be represented
- Uses value 0 to 127 / one byte
- Many characters used in other languages cannot be represented
- In extended ASCII the characters from 128 to 255 may be coded differently in different systems
Why “differently”? 0–127 is fixed on all systems (65 is always A), but 128–255 has no standard — e.g. Arabic “Alif” could be 129 on one system and another value on another. Customisable = not compatible.
Q: How is Unicode designed to overcome the disadvantages of ASCII?
- Uses 16, 24, 32 bits
- Unicode is designed to be a superset of ASCII
- Designed so that most characters in other languages can be represented
6. A computer uses the ASCII character set.
(a) State the number of characters represented by ASCII and extended ASCII [2]
ASCII: 128 | Extended ASCII: 256
(not 127 — 127 + 1 for the all-zero code = 128)
(b) Explain how a word such as ‘HOUSE’ is represented by the ASCII character set. [2]
- Each character has its own unique code
- Each character in the word is replaced by its code
- The codes are stored in the order in the word
e.g. H, O, U, S, E each get their own binary code, stored one after another in the same order as the word.
(c) Unicode is a different character set. The Unicode value for the character ‘1’ is denary value 49.
(i) Write the hexadecimal value for the Unicode character ‘1’. [1]
(ii) Write the denary value for the Unicode character ‘5’. [1]
Digits are consecutive in the code — write the count-up to avoid confusion. (Binary code is not asked here — Unicode value = denary/hex.)
10. Quick Recap — Full Chapter Cheat-Sheet
- bit (smallest) · 4 bits = nibble · 8 bits = 1 byte
- Binary prefixes (÷/× 1024): kibi · mebi · gibi · tebi — Decimal (÷/× 1000): kilo · mega · giga · tera
- bigger → smaller: multiply · smaller → bigger: divide · bits → bytes: ÷ 8 first
- Denary → binary: put 1s so the place values add to the number
- Binary → denary: add only the place values with a 1
- Binary → hex: groups of 4 from the right → 8 4 2 1 → > 9 use A=10 … F=15
- Denary → hex: denary → binary → hex | Hex → denary: hex → binary → denary
- 4-bit code for each denary digit (digits ≤ 9) · 54 = 0101 0100 · 653 = 0110 0101 0011
- BCD → denary: groups of 4 from right → digits · uses: calculators, digital clocks (single digits)
- Always check: is it BCD or binary?
- 0+0=0 · 0+1=1 · 1+1=0 carry 1 · 1+1+1=1 carry 1 · fill gaps with 0
- Negative: ignore sign → binary → invert (1’s) → +1 (2’s) · first bit 1 ⇒ negative · unsigned: no sign
- Subtract: apply 2’s complement to the number being subtracted, then add (drop overflow bit)
- Overflow: result larger than can be stored in the given number of bits
- ASCII: 7 bits · 128 chars (0–127) · Extended ASCII: 8 bits · 256 chars (128–255 not standard)
- Unicode: 16/24/32 bits · superset of ASCII · most world languages
- A = 65 · a = 97 (add 1 per letter) · ‘1’ = 49, ‘5’ = 53 · word = each character’s code in order