Student
IGCSE
Topic 1 · IGCSE 0478

Data Representation

3 subtopics · 8 interactive lessons · 1 test
Your progress
0%
1.1 Number Systems
1.2 Text, Sound & Images
1.3 Storage & Compression
Step 1 of 8 · Subtopic 1.1

Everything is a 1 or a 0

Computers don't understand words or pictures the way we do. Deep inside, they only understand two things: electricity flowing, or not flowing. We represent those two states as 1 and 0. That's binary.

Click the switch to see what happens
⚡
Power
0
No electricity flowing
The switch is open. No current flows. The computer reads this as 0.
Key terms
Bit
A single binary digit. Either 0 or 1
Binary
A base 2 number system using only 0s and 1s
Transistor
A tiny electronic switch inside a computer chip
A modern CPU contains over 50 billion transistors. Each one stores one bit: a single 0 or 1.
Step 2 of 8 · Subtopic 1.1

Converting Denary to Binary

Denary is the number system you use every day. Base 10, digits 0 through 9. To convert a denary number to binary, we use the division by 2 method. Divide by 2, keep the remainder. Repeat until you reach 0. Read the remainders bottom to top.

Watch it happen, then try it yourself
Converting 13 to binary
🎯 Your turn
Convert 25 to binary
Hint: Use the division by 2 method. Divide 25 by 2, keep the remainder, repeat.
Step 3 of 8 · Subtopic 1.1

Converting Binary to Denary

To convert binary back to denary, we use powers of 2. Each bit position has a value, starting from the right at 2¹⁰ = 1, doubling each time you move left. Click each bit that is a 1 to add its value to the total.

Click the bits that are 1 to add their value
Total:
0
🎯 Your turn
Convert 10110 to denary
Step 4 of 8 · Subtopic 1.1

Hexadecimal

Binary is powerful but hard for humans to read. Imagine having to write 10101111 every time instead of AF. Hexadecimal is a base 16 number system that gives us a much shorter way to represent binary data, and computers use it everywhere.

The same value, three ways
Denary
175
Base 10
→
Binary
10101111
Base 2 · 8 digits
→
Hexadecimal
AF
Base 16 · 2 digits
AF is much easier to read and write than 10101111. They mean exactly the same thing.
Fill in the hex digit for each denary value. You already know 0–9. For the letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
Each hex digit represents exactly 4 bits (one nibble). Pick a hex digit to see its binary equivalent.
?
?
?
?
8421
Key terms
Hexadecimal
A base 16 number system using digits 0–9 and A–F
Nibble
A group of 4 bits. One hex digit represents exactly one nibble
Base 16
Each digit position is worth 16 times the position to its right
Hexadecimal is used in MAC addresses, colour codes (#FF5733), memory addresses and error codes. Anywhere binary needs to be human-readable.
Step 5 of 8 · Subtopic 1.1

Hexadecimal Conversions

Now that you know the 16 hex digits, let's learn how to convert between hexadecimal, denary and binary. There are four conversions to master. Watch each one, then try it yourself.

Choose a conversion to learn
Denary to Hex: divide by 16 and convert remainders
Converting 175 to hex
🎯 Your turn
Convert 44 to hex
Hint: 44 ÷ 16 = 2 remainder 12. What is 12 in hex?
Hex to Denary: multiply each digit by its power of 16
🎯 Your turn
Convert 2C to denary
Hint: 2 × 16 + 12 × 1 = ?
Hex to Binary: convert each digit into a 4-bit nibble
🎯 Your turn
Convert B4 to binary
Hint: B = 11 = 1011, 4 = 0100. Put them together.
Binary to Hex: group into nibbles of 4, then convert each group
🎯 Your turn
Convert 11010111 to hex
Hint: Split into 1101 and 0111. Convert each nibble to hex.
Step 6 of 8 · Subtopic 1.1

Binary Addition and Overflow

Adding binary numbers works the same way as adding denary numbers in columns. The difference is that in binary, there are only two digits — 0 and 1. So when you add 1 + 1, you cannot write 2 because 2 does not exist in binary. Instead you write 0 and carry 1 to the next column. There are only four rules to learn.

Click each rule to see what it means
0 + 0
=
?
0 + 1
=
?
1 + 1
=
?
1 + 1 + 1
=
?
Watch a full addition step by step. Click to advance each column.
Carry row
🎯 Your turn
Add these two 8-bit binary numbers
Hint: Work column by column from right to left. Remember 1+1 = 10 in binary.
What is overflow?

An 8-bit register can only hold 8 bits. The largest value it can store is 11111111 which is 255 in denary. When two numbers add up to more than 255, the result needs a 9th bit. That 9th bit gets cut off and the result stored in the register is wrong. This is called an overflow error.

🎯 Which addition causes overflow?
Step 7 of 8 · Subtopic 1.1

Logical Binary Shifts

A binary shift moves every bit in a register left or right by a number of positions. Zeros fill in from the opposite end and any bits that fall off the edge are permanently lost. The most useful thing about shifts is what they do to the value stored — shifting left multiplies by 2 and shifting right divides by 2.

Left shift → multiply by 2
Start: 3 in denary
0
Right shift → divide by 2
Start: 12 in denary
0
Watch out for lost bits

If a 1 bit falls off the end of the register it is gone. The value you get back is not double or half what you started with. It is just wrong. This is the same idea as overflow but caused by shifting rather than addition.

Try shifting 01100000 (96) left three times and watch what happens
Denary value: 96
🎯 Your turn
Start with 00000101. Shift left by 2 positions. What is the result?
Hint: Shift every bit two places to the left. Fill in two zeros on the right. What value does that give you in denary? Remember, shifting left by 2 multiplies by 4.
Start with 00101000. Shift right by 3 positions. What is the result?
Hint: Shift every bit three places to the right. Fill in three zeros on the left. Shifting right by 3 divides by 8.
Step 8 of 8 · Subtopic 1.1

Two's Complement

Computers only store 0s and 1s. There is no minus sign in binary. Two's complement solves this by using the leftmost bit — the Most Significant Bit — as a sign bit. If the MSB is 0, the number is positive. If the MSB is 1, the number is negative. Everything else stays the same.

Click the MSB (leftmost bit) to see how the sign changes
Positive
+5
MSB is 0 — this is a positive number.
Method 1
Flip and add 1

To convert a positive binary number to its negative two's complement form: flip every bit, then add 1. Two steps, every time, no exceptions.

Converting +5 (00000101) to -5
Start
+5 in binary
Method 2
MSB weight method

In two's complement, the MSB has a negative weight of -128 instead of 128. Every other bit position stays the same. To find the value, add up all the positions where there is a 1 — but treat the MSB as -128.

Click each bit that is 1 to build the total. The MSB works differently.
Total:
0
Both methods, same number, same result
Flip and add 1
00000101 (start: +5)
11111010 (flip all bits)
11111011 (add 1)
Result: -5
MSB weight method
11111011
-128 + 64 + 32 + 16 + 8 + 2 + 1
-128 + 123 = -5
Result: -5
Two different methods. One answer. Use whichever you find easier — both are accepted in the exam.
🎯 Your turn
Convert +19 to its 8-bit two's complement form
Hint: Write +19 in binary first, then flip every bit, then add 1.
What denary value does 11110110 represent in two's complement?
Hint: The MSB is 1 so this is negative. Use the MSB weight method: -128 + the values of the other 1 bits.
Step 1 of 5 · Subtopic 1.2

How computers represent text

Look at the keyboard in front of you. Every key is a character. But when you press A, your computer does not receive the letter A. Your computer only understands one thing.

Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
Z
X
C
V
B
N
M
SPACE
When you press A, what does your computer actually receive?
Step 2 of 5 · Subtopic 1.2

How computers represent sound

Sound is a wave. Your computer cannot store a wave directly because it only understands binary numbers. Instead, it takes snapshots of the wave at regular intervals and stores each snapshot as a binary number. This process is called sampling.

Press the button to take more samples and see what happens to the reconstruction
Samples per second: 8
Sample rate

Sample rate is how many snapshots are taken per second. It is measured in Hertz (Hz) or kilohertz (kHz). The more samples taken per second, the more accurately the sound is recreated — but the larger the file becomes.

8,000 Hz
Telephone quality
Good enough for voice, not music
44,100 Hz
CD quality
44,100 samples every second
96,000 Hz
Studio quality
Professional recording standard
Sample resolution (bit depth)

Sample resolution is how many bits are used to store each individual snapshot. More bits per sample means more possible values, which means a more accurate recording — and a bigger file.

Data storage units

Before calculating file sizes you need to know the storage units. Cambridge always uses 1024 — never 1000. Using 1000 in an exam will cost you marks.

UnitAbbreviationEqual to
BitbSmallest unit of data — a single 0 or 1
Nibble-4 bits
ByteB8 bits
KibibyteKiB1,024 bytes
MebibyteMiB1,024 KiB
GibibyteGiB1,024 MiB
TebibyteTiB1,024 GiB
PebibytePiB1,024 TiB
ExbibyteEiB1,024 PiB
Always use 1024 not 1000 in Cambridge calculations. KiB stands for kibibyte. It is not the same as kilobyte (KB) which uses 1000.
Calculating file size

The formula is: sample rate × sample resolution × duration. This gives you the size in bits. Then you convert down through the units.

Example: sample rate 44,100 Hz, resolution 16 bits, duration 10 seconds
🎯 Your turn

A sound file is recorded at 22,050 Hz, with a sample resolution of 8 bits, for 20 seconds.

What is the file size in bits?
Hint: sample rate x resolution x duration = bits
Now convert that to KiB. Round to 2 decimal places.
Hint: bits / 8 = bytes. bytes / 1024 = KiB
Finally convert to MiB. Round to 4 decimal places.
Hint: KiB / 1024 = MiB
Step 3 of 5 · Subtopic 1.2

How computers represent images

Every image on a screen is made of tiny squares called pixels. Each pixel stores a colour value as a binary number. The quality of an image comes down to two things: how many pixels there are, and how many bits are used to store each one.

Click the image to zoom in and see the individual pixels
Click to zoom in
Zoom level
1x
Pixels visible
200 x 200
Each square is
1 pixel
Resolution

Resolution is the number of pixels in an image, given as width x height. A higher resolution means more pixels, a sharper image, and a larger file size.

Colour depth

Colour depth is the number of bits used to store each pixel's colour. More bits means more possible colour values, which means a more accurate image and a larger file.

24-bit colour is called true colour. With over 16 million possible values per pixel, the human eye cannot distinguish individual shades.
Calculating image file size

The formula is: width × height × colour depth. This gives the file size in bits. Then convert using the same units as before.

Example: image is 800 x 600 pixels, colour depth is 24 bits
🎯 Your turn

An image is 1024 x 768 pixels with a colour depth of 16 bits.

What is the file size in bits?
Hint: width x height x colour depth
Now convert to MiB. Round to 2 decimal places.
Hint: bits / 8 = bytes. bytes / 1024 = KiB. KiB / 1024 = MiB.
Step 1 of 4 · Subtopic 1.3

Data Storage and Compression

Every time you upload a photo, send a file on WhatsApp, or submit work online, there is a size limit. Compression is how we reduce the size of a file so it fits within those limits. There are two types and they work in very different ways.

Think of it this way
🛀
Lossy compression
You are packing for a holiday but your suitcase is too full. You leave some things behind to make it fit. When you arrive, those items are gone permanently. You cannot get them back.
Data is permanently removed
🧥
Lossless compression
You fold everything with precision and efficiency. Your suitcase closes and everything fits. When you arrive, unpack and nothing is missing. Every item is exactly as you left it.
No data is lost
Lossy
Lossy compression

Lossy compression permanently removes data from a file to make it smaller. The quality of the file is reduced and the original cannot be recovered. It is used when a small reduction in quality is acceptable.

JPEG
Images
Removes fine colour detail the eye can barely see
MP3
Audio
Removes sounds outside human hearing range
MP4
Video
Reduces detail in parts of the frame that change less
Drag the slider to see the effect of lossy compression
Heavy compression High quality
Quality: 100% · File size: large
Lossless
Lossless compression

Lossless compression reduces file size without removing any data. The original file can be perfectly reconstructed from the compressed version. It is used when the exact original data must be preserved.

ZIP
Archives
Groups and compresses files without losing data
PNG
Images
Compresses image data perfectly
FLAC
Audio
Lossless audio — identical to the original recording
Run Length Encoding (RLE)

Run Length Encoding is a lossless compression algorithm Cambridge specifically asks about. Instead of storing every value individually, RLE stores how many times each value repeats in a row. A long sequence of the same value is replaced by just two pieces of information: the value and its count.

Watch RLE compress a row of pixel colours
Now try encoding this yourself
Count the consecutive repeats of each colour and enter the RLE code below. Format: count then letter, e.g. 4R3B means 4 reds then 3 blues.
Key terms
Compression
Reducing the size of a file so it takes up less storage or transfers faster
Lossy
Compression that permanently removes data. Smaller file, lower quality, cannot be reversed
Lossless
Compression that preserves all data. The original file can be perfectly reconstructed
RLE
Run Length Encoding. A lossless algorithm that replaces repeated values with a count and the value
🎯 Your turn
A student saves a photo as JPEG and as PNG. The JPEG is smaller. Which type of compression does JPEG use, and what does that mean for the image?
Decode this RLE sequence: 5W3B2W1B
Hint: 5W means five Ws, 3B means three Bs, and so on. Write them all out.
🔒
Worksheet locked
Complete all three subtopics in the Learn tab to unlock the worksheet.
Resources · Topic 1

Quick Reference

Everything you need for Topic 1 in one place. Come back to this tab any time.

Powers of 2
Power20212223 24252627
Value1248163264128
Binary, Denary and Hex: 0 to 15
DenaryBinaryHex
Hexadecimal Digits
Denary 01234567 89101112131415
Hex 01234567 89ABCDEF
Conversion Methods
Denary to Binary
Divide by 2 repeatedly. Keep each remainder. Read remainders from bottom to top.
Binary to Denary
Assign powers of 2 from right (20 = 1). Add up the values where a 1 appears.
Denary to Hex
Divide by 16. Convert remainders using the hex digit table. Read from bottom to top.
Hex to Denary
Start from the rightmost digit at 160. Multiply each digit by its power of 16 and add them up.
Hex to Binary
Convert each hex digit individually into a 4-bit binary group (nibble).
Binary to Hex
Group bits into nibbles of 4 from the right. Convert each nibble to its hex digit.
Binary Addition Rules
0 + 0 = 0
No carry.
0 + 1 = 1
No carry.
1 + 1 = 10
Write 0, carry 1. Because 2 in denary = 10 in binary.
1 + 1 + 1 = 11
Write 1, carry 1. Because 3 in denary = 11 in binary.
Overflow
Occurs when the result exceeds 255 in an 8-bit register. The extra bit is lost and the stored value is wrong.
Logical Binary Shifts
Left shift by 1
Multiplies the value by 2. Bits move left, a 0 fills in from the right. Leftmost bit is lost.
Right shift by 1
Divides the value by 2 (integer division). Bits move right, a 0 fills in from the left. Rightmost bit is lost.
Multiple shifts
Shifting left by n multiplies by 2n. Shifting right by n divides by 2n.
Lost bits
If a 1 bit falls off the end, the result is no longer correct. The mathematical relationship breaks down.
Two's Complement
Sign bit (MSB)
The leftmost bit is the sign bit. MSB = 0 means positive. MSB = 1 means negative.
Method 1: Flip and add 1
To convert a positive number to negative: flip every bit, then add 1 to the result.
Method 2: MSB weight
The MSB has a value of -128 instead of 128. Add up all positions where a 1 appears, treating the MSB as -128.
Range (8-bit)
Two's complement represents values from -128 to +127.
🔒
Test locked
Complete all subtopics in the Learn tab to unlock the Topic 1 test.