Data Representation Grade 10
Computers only understand two states: on (1) and off (0). Everything — text, images, sound, video — must first be converted to those 1s and 0s before a computer can process it. This page explains how that conversion works.
Why Only 1s and 0s?
Deep inside your computer, everything is built from tiny transistors — microscopic electronic switches. Each switch can only be in one of two states: on (1) or off (0). This is called binary because there are only two options.
A single 1 or 0 is called a bit (short for binary digit). On its own, one bit can only represent two things. But group 8 bits together into a byte, and suddenly you can represent 256 different values (28 = 256) — enough for every letter, digit, and common symbol.
Think of a light switch: it is either ON or OFF — that's 1 bit. Now imagine a row of 8 light switches. Each combination of on/off gives a different pattern — 256 possible combinations. That's how a computer stores one character.
Bits and Bytes — Visual Diagram
Eight bits grouped together form one byte. The example below shows the byte 01000001 — the binary code for the letter A in ASCII.
Number Systems Overview
| System | Base | Digits used | Used for |
|---|---|---|---|
| Decimal | 10 | 0–9 | Everyday counting — the system humans naturally use |
| Binary | 2 | 0, 1 | Internal computer data — all data is stored this way |
| Hexadecimal | 16 | 0–9, A–F | Colour codes (#FF5733), memory addresses, shorter binary notation |
Binary (Base 2)
In decimal, each column is worth 10× the column to its right (1, 10, 100, 1000…). In binary, each column is worth 2× the column to its right — these are the powers of 2.
Memorise the 8 place values: 128, 64, 32, 16, 8, 4, 2, 1. Every binary conversion uses these numbers. Notice each one doubles: 1×2=2, 2×2=4, 4×2=8, 8×2=16, and so on.
Step-by-Step Conversion Examples
Binary → Decimal
Multiply each bit by its place value, then add them all up. Only count the columns where the bit is 1.
Place value: 128 64 32 16 8 4 2 1
Bit: 0 0 1 0 1 1 0 1
Calculation: 0 + 0 + 32 + 0 + 8 + 4 + 0 + 1
= 45
Place value: 16 8 4 2 1
Bit: 1 0 1 1 0
Calculation: 16 + 0 + 4 + 2 + 0
= 22
Decimal → Binary (Divide by 2 Method)
Divide the number by 2 repeatedly. Write down each remainder. Read the remainders from bottom to top.
25 ÷ 2 = 12 remainder 1 ← LSB (written last, read first from bottom)
12 ÷ 2 = 6 remainder 0
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1 ← MSB (written first, read last from bottom)
Read remainders bottom to top: 1 1 0 0 1
= 11001₂
Verify: 16 + 8 + 0 + 0 + 1 = 25 ✓
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Read bottom to top: 1 1 0 1 = 1101₂
Verify: 8 + 4 + 0 + 1 = 13 ✓
Hexadecimal (Base 16)
Hexadecimal (hex) uses 16 symbols: the digits 0–9, then the letters A–F for values 10–15. Because one hex digit represents exactly 4 binary bits, hex is a much shorter way to write binary numbers. For example, 11111111 in binary is just FF in hex.
Hex Digit Table
| Decimal | Binary (4-bit) | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
Hex → Decimal Conversion
Each position in hex is worth 16× the position to its right (just like binary uses powers of 2, hex uses powers of 16).
2A₁₆ has two digits: 2 and A
Position: 16¹ 16⁰
Digit: 2 A (=10)
Value: 2×16 + 10×1
= 32 + 10
= 42₁₀
3F₁₆:
3 × 16¹ = 3 × 16 = 48
F × 16⁰ = 15 × 1 = 15
----
63₁₀
Decimal → Hex Conversion (Divide by 16)
200 ÷ 16 = 12 remainder 8 → 8
12 ÷ 16 = 0 remainder 12 → C (12 in hex = C)
Read remainders bottom to top: C 8 → C8₁₆
Verify: 12 × 16 + 8 = 192 + 8 = 200 ✓
Hex is everywhere in computing. Colour codes in web design use hex: #FF0000 = red (255 red, 0 green, 0 blue). Memory addresses in low-level programming are hex. Even Delphi lets you write hex literals with a dollar sign: $FF = 255.
ASCII — Storing Text
A computer stores text by mapping each character to a number. The most common mapping is ASCII (American Standard Code for Information Interchange). Each character has a unique number — a code — which is then stored in binary.
Key ASCII Values to Memorise
| Character | ASCII decimal | Binary (8-bit) | Notes |
|---|---|---|---|
| Space | 32 | 00100000 | The space bar produces this |
| 0 | 48 | 00110000 | The digit zero (not the letter O) |
| 9 | 57 | 00111001 | Digits 0–9 = ASCII 48–57 |
| A | 65 | 01000001 | First uppercase letter |
| B | 66 | 01000010 | |
| Z | 90 | 01011010 | Last uppercase letter |
| a | 97 | 01100001 | First lowercase — exactly 32 more than 'A' |
| z | 122 | 01111010 | Last lowercase letter |
The difference between an uppercase letter and its lowercase version is always 32 in ASCII. So Ord('A') = 65 and Ord('a') = 97 (65 + 32 = 97). This is how Delphi's UpCase() function works internally — it subtracts 32.
Unicode and UTF-8
| Standard | Description | Example |
|---|---|---|
| ASCII | 7-bit (128 chars) or 8-bit (256). English letters, digits, symbols only. | 'A' = 65 |
| UTF-8 | Variable length (1–4 bytes). Backward compatible with ASCII. Most common on the web. | Supports Zulu, Xhosa, Arabic, Chinese… |
| Unicode | Universal standard — 140 000+ characters including all world languages. | isiZulu characters, emoji |
Data Representation in Delphi
// Ord: char → ASCII number
iCode := Ord('A'); // = 65
iCode := Ord('a'); // = 97
// Chr: ASCII number → char
cChar := Chr(65); // = 'A'
cChar := Chr(97); // = 'a'
// Convert lowercase to uppercase using the +32 rule:
cUpper := Chr(Ord(cLower) - 32);
// Print ASCII values of each character in a string
for i := 1 to Length(sText) do
memOut.Lines.Add(sText[i] + ' = ' + IntToStr(Ord(sText[i])));Storage Units
| Unit | Symbol | Size | Real-world example |
|---|---|---|---|
| Bit | b | Single 0 or 1 | One transistor state |
| Byte | B | 8 bits | One character, e.g. 'A' |
| Kilobyte | KB | 1 024 bytes | One page of plain text (~1 000 characters) |
| Megabyte | MB | 1 024 KB | A small JPEG photo, a 3-min MP3 song |
| Gigabyte | GB | 1 024 MB | A 2-hour HD movie, a mobile game |
| Terabyte | TB | 1 024 GB | A standard laptop hard drive |
| Petabyte | PB | 1 024 TB | Large data centres, cloud storage |
Computers work in binary (powers of 2). 210 = 1 024, which is close to 1 000 but not equal. So 1 KB = 1 024 bytes (not 1 000). Hard drive manufacturers sometimes use 1 000 to make drives sound bigger — that's why a "500 GB" drive shows as ~465 GB in Windows.