← Back to subjects
0
Cambridge IGCSE Computer Science (0478) · Data representation
Mini-Lesson

Data representation

Computers store everything — numbers, text, images and sound — as binary: patterns of 0s and 1s. This mini-lesson covers number systems (binary, denary, hexadecimal) and conversions, binary arithmetic and logical shifts, two’s complement (Extended), how text, images and sound are represented, data storage units, and compression.

text · images sound · numbers encoded as 1 0 1 1 0 0 1 a computer only understands binary

Work through each screen, answer the questions (some are conversions and calculations) and collect ⭐ stars. Watch for the Extended flag. Press Start when ready.

Number systems · binary & denary

Binary and denary

Denary (decimal) is base 10 — digits 0–9. Binary is base 2 — only 0 and 1. Each binary digit is a bit; 8 bits make a byte. In an 8-bit byte each column has a place value:

128 64 32 16 8 4 2 1 00101101 00101101 = 32 + 8 + 4 + 1 = 45
Add the place values wherever there is a 1: here 32 + 8 + 4 + 1 = 45.
Worked example — denary to binary (45)

Fit 45 into 128 64 32 16 8 4 2 1: 45 = 32 + 8 + 4 + 1.

So 45 = 0010 1101.

Tip: the largest number in 8 bits is 11111111 = 255 (that’s 256 different values, 0–255).

Convert

Your turn — binary to denary

1Convert the binary number 10011010 to denary.
Hint: 128 + 16 + 8 + 2.
Quick check

Denary to binary

?Which 8-bit binary number represents the denary value 100?
Number systems · hexadecimal

Hexadecimal

Hexadecimal is base 16, using digits 0–9 then A B C D E F for 10–15. It is a shorthand for binary: one hex digit = exactly 4 bits (a nibble), so a byte is just two hex digits.

1100 1000 C 8 1100 = 12 = C 1000 = 8
11001000 splits into 1100 (C) and 1000 (8), so it is C8 in hex.
Worked example — hex C8 to denary

C = 12, so C8 = (12 × 16) + 8 = 192 + 8 = 200.

Uses: hex is used for MAC addresses, IP (IPv6) addresses, colour codes (e.g. #FF0000) and memory dumps — it is shorter and easier for humans than long binary strings.

Convert

Your turn — hex to denary

2Convert the hexadecimal number 2F to denary.
Hint: 2 = 2×16 = 32, and F = 15. Add them.
Quick check

Denary to hex

?What is the denary number 200 written in hexadecimal?
Binary arithmetic & logical shifts

Binary addition & logical shifts

Adding binary works like denary, but you carry when a column reaches 2 (10 in binary): 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).

Worked example — 01001111 + 00101011

79 + 43 in denary. Adding the bits with carries gives 01111010 = 122. Check: 64+32+16+8+2 = 122.

A logical shift moves all the bits left or right, filling the empty end with 0. A left shift by 1 multiplies the number by 2; a right shift by 1 divides by 2 (whole-number part). Bits shifted out of the end are lost.

00000110 = 6 → shift left 1 → 00001100 = 12 every bit moves one place left, a 0 comes in on the right → ×2

Overflow: if a sum needs more than 8 bits (over 255), the extra carry can’t be stored — this is an overflow error.

Calculate

Your turn — binary addition

3Add the binary numbers 00110101 + 00010110. Give the denary value of the answer.
Hint: 00110101 = 53 and 00010110 = 22. 53 + 22.
Quick check

Logical shift

?The 8-bit number 00010100 (denary 20) is given a logical shift right by 2 places. What is the new denary value?
Extended · two’s complement

Two’s complement (negative numbers)

To store negative whole numbers, computers use two’s complement. In 8-bit two’s complement the left-most bit is negative: its place value is −128, and the rest stay 64, 32 … 1.

Worked example — write −5 in 8-bit two’s complement

1. Write +5 = 00000101.

2. Invert every bit (flip 0↔1) → 11111010.

3. Add 1 → 11111011.

Check: −128 + 64 + 32 + 16 + 8 + 2 + 1 = −5. ✓

Spot a negative: if the left-most bit is 1, the number is negative. Range in 8 bits is −128 to +127.

Extended · Calculate

Your turn — two’s complement

4The 8-bit two’s complement number 11110000 represents which denary value? (Remember the left bit is −128.)
Hint: −128 + 64 + 32 + 16 = ? (the last four bits are 0).
Representing text, sound & images

Text, sound & images

  • Text — each character has a binary code in a character set. ASCII uses 7 (or 8) bits; Unicode uses more bits so it can represent many more characters, including other alphabets and emoji.
  • Images (bitmaps) — made of pixels. Colour depth = number of bits per pixel (more bits → more colours). Resolution = number of pixels (width × height). File size (bits) = width × height × colour depth.
  • Sound — the analogue wave is sampled at regular intervals. Sample rate = samples per second (Hz); sample resolution = bits per sample. Higher values → more accurate sound but larger files.
each red dot is a sample: measure the height, store as binary
Sampling turns a smooth wave into numbers the computer can store.
Calculate

Your turn — image file size

?A bitmap image is 10 pixels wide and 8 pixels tall, with a colour depth of 4 bits. What is its file size in bits?
Data storage & units

Measuring data storage

The smallest unit is the bit; 8 bits = 1 byte. Larger units go up in 1024s (210):

  • 1 kibibyte (KiB) = 1024 bytes
  • 1 mebibyte (MiB) = 1024 KiB
  • 1 gibibyte (GiB) = 1024 MiB
  • 1 tebibyte (TiB) = 1024 GiB

Note: in everyday adverts kilo/mega often mean 1000, but Cambridge 0478 uses the IEC units (kibi, mebi, gibi…) which are powers of 1024.

Match it

Match the term to its meaning

Tap a description on the left, then its matching term on the right.

Description
Term
Compression

Compression

Compression reduces a file’s size so it needs less storage and transmits faster. There are two types:

  • Losslessno data is lost; the original file can be perfectly rebuilt. Uses techniques like run-length encoding (RLE). Used for text and program files.
  • Lossy — some data is permanently removed (e.g. detail the eye/ear barely notices). Gives much smaller files but lower quality. Used for photos (JPEG) and music (MP3).

Key difference: lossless can be fully reversed; lossy cannot — the removed data is gone for good.

Quick check

Which compression?

?A programmer must compress a text file so it can be perfectly restored later with no characters lost. Which type of compression should they use?
Recap

The big ideas to know

Number systems: binary (base 2) · denary (base 10) · hex (base 16, 1 digit = 4 bits)

Conversions: add place values 128…1; hex digit = nibble

Arithmetic: binary addition (carry at 2); logical shift left ×2, right ÷2; overflow

Extended: two’s complement — left bit is −128; range −128 to +127

Media: text (ASCII/Unicode) · images (resolution × colour depth) · sound (sample rate × resolution)

Storage: 8 bits = 1 byte; units go up in 1024s. Compression: lossless (reversible) vs lossy (permanent)

You’ve covered the whole of Data representation. Press Finish to see your score.

🏆

Mini-lesson complete!

⭐⭐⭐

You’ve worked through Data representation for Cambridge IGCSE Computer Science. 🎉

Your stars: 0 / 0

Next: test yourself in the Evaluate stage Confidence Quiz, then lock it in with Verify.

📣 Smashed it? Share your score

Challenge a mate to beat your stars, or show a parent how you got on.

→ Back to all subjects