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.

ANALOGY

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.

One Byte = 8 Bits  →  01000001 = 'A' (ASCII 65) 0 bit 7 1 bit 6 0 bit 5 0 bit 4 0 bit 3 0 bit 2 0 bit 1 1 bit 0 ← 1 byte (8 bits) →

Number Systems Overview

SystemBaseDigits usedUsed for
Decimal100–9Everyday counting — the system humans naturally use
Binary20, 1Internal computer data — all data is stored this way
Hexadecimal160–9, A–FColour 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.

Binary Place Values (8-bit) 2⁷ 2⁶ 2⁵ 2⁴ 2⁰ 128 64 32 16 8 4 2 1 ← Most significant bit (MSB)                     Least significant bit (LSB) →
TIP — Learn These!

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.

Example: 00101101 in binary → decimal
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
Example: 10110 in binary → decimal
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.

Example: 25 in decimal → binary
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 ✓
Example: 13 in decimal → binary
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

DecimalBinary (4-bit)Hex
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F

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).

Example: 2A (hex) → decimal
2A₁₆  has two digits:  2  and  A

Position:   16¹    16⁰
Digit:        2      A (=10)
Value:     2×16  + 10×1
         =   32  +   10
         =       42₁₀
Example: 3F (hex) → decimal
3F₁₆:
  3 × 16¹ = 3 × 16 = 48
  F × 16⁰ = 15 × 1 = 15
                     ----
                      63₁₀

Decimal → Hex Conversion (Divide by 16)

Example: 200 (decimal) → hex
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 ✓
WHERE YOU SEE HEX

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

CharacterASCII decimalBinary (8-bit)Notes
Space3200100000The space bar produces this
04800110000The digit zero (not the letter O)
95700111001Digits 0–9 = ASCII 48–57
A6501000001First uppercase letter
B6601000010
Z9001011010Last uppercase letter
a9701100001First lowercase — exactly 32 more than 'A'
z12201111010Last lowercase letter
EXAM TIP — The +32 Rule

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

StandardDescriptionExample
ASCII7-bit (128 chars) or 8-bit (256). English letters, digits, symbols only.'A' = 65
UTF-8Variable length (1–4 bytes). Backward compatible with ASCII. Most common on the web.Supports Zulu, Xhosa, Arabic, Chinese…
UnicodeUniversal standard — 140 000+ characters including all world languages.isiZulu characters, emoji

Data Representation in Delphi

Delphi — Ord and Chr with ASCII
// 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

UnitSymbolSizeReal-world example
BitbSingle 0 or 1One transistor state
ByteB8 bitsOne character, e.g. 'A'
KilobyteKB1 024 bytesOne page of plain text (~1 000 characters)
MegabyteMB1 024 KBA small JPEG photo, a 3-min MP3 song
GigabyteGB1 024 MBA 2-hour HD movie, a mobile game
TerabyteTB1 024 GBA standard laptop hard drive
PetabytePB1 024 TBLarge data centres, cloud storage
TIP — Why 1 024 not 1 000?

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.