← 💻 Computer Science

Cambridge IGCSE 0478 · Topic 1 of 10

Data representation

How computers store numbers, text, sound and images in binary, how to convert between number systems, and how file size and compression work.

📌 Key points

  1. Computers use binary (base 2) because they are made of switches and logic gates that have only two states (on/off, 1/0), so all data must be converted to binary before it can be processed.
  2. Denary is base 10, binary is base 2 and hexadecimal is base 16 (digits 0–9 then A–F, where A = 10 and F = 15); one hex digit stands for exactly 4 bits (a nibble).
  3. Hexadecimal is used because it is shorter and easier for humans to read, write and remember than binary, so fewer mistakes are made; uses include MAC addresses, HTML colour codes, error codes and memory dumps.
  4. Binary addition rules: 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1), 1 + 1 + 1 = 11 (write 1, carry 1); an overflow error happens when the result needs more bits than the register can hold, e.g. a value greater than 255 in an 8-bit register.
  5. A logical left shift of n places multiplies a positive binary integer by 2n and a logical right shift divides it by 2n; bits shifted off the end are lost and zeros fill the empty places.
  6. Two's complement stores negative integers: in 8 bits the most significant bit has the place value −128, so the range is −128 to +127; to make a negative number, write the positive value, flip every bit and add 1.
  7. Text is stored using a character set: ASCII uses 7 bits (128 characters, extended ASCII uses 8 bits for 256), while Unicode uses more bits per character so it can represent many more characters, including other alphabets and emojis.
  8. Sound is stored by sampling the analogue wave: the sample rate is the number of samples taken per second and the sample resolution is the number of bits per sample; increasing either gives a more accurate recording but a larger file.
  9. An image is made of pixels: the resolution is the number of pixels (width × height) and the colour depth is the number of bits per pixel; image file size in bits = width × height × colour depth.
  10. Units: 4 bits = 1 nibble, 8 bits = 1 byte, 1 KiB = 1024 bytes, 1 MiB = 1024 KiB, then GiB, TiB, PiB, EiB; lossy compression permanently removes data (e.g. JPEG, MP3), lossless compression (e.g. run-length encoding) lets the original be rebuilt exactly.

📖 Key terms

Overflow error
When the result of a calculation is too large to be stored in the number of bits available in the register.
Most significant bit (MSB)
The leftmost bit, with the largest place value; in two's complement it has a negative value.
Character set
All the characters a computer can represent, each with its own unique binary code.
Sample rate
The number of sound samples taken per second, measured in hertz (Hz).
Colour depth
The number of bits used to store the colour of each pixel.
Lossy compression
Reduces file size by permanently removing data; the original file cannot be restored.
Run-length encoding (RLE)
Lossless compression that stores a run of identical values as the value and the number of times it repeats.

✏️ Worked example

Convert the denary number 181 into 8-bit binary and into hexadecimal.

  1. Write the place values: 128, 64, 32, 16, 8, 4, 2, 1.
  2. 181 − 128 = 53, 53 − 32 = 21, 21 − 16 = 5, 5 − 4 = 1, 1 − 1 = 0, so there are 1s under 128, 32, 16, 4 and 1.
  3. Binary: 10110101 (check: 128 + 32 + 16 + 4 + 1 = 181).
  4. Split into nibbles: 1011 and 0101. 1011 = 11 = B and 0101 = 5.
  5. Hexadecimal: B5 (check: 11 × 16 + 5 = 181).
💡 Exam tip

In file size questions show every step: multiply to get bits, divide by 8 for bytes, then divide by 1024 for KiB (and again for MiB). Most lost marks come from forgetting the ÷ 8.

Test yourself8 questions from a bank of 18. A new mix every time.
Start the quiz →

It’s bedtime! 😴

It’s late, and even Numo is getting sleepy. The best thing you can do for your learning now is… go to sleep!

✨ Sleep helps you

  • 🧠 remember what you learned today: your brain saves it while you sleep
  • 🌱 grow and stay healthy
  • ⚡ wake up with energy, ready to learn and play
  • 😊 feel happy and calm

🦉 Going to bed late can make you

  • 😩 tired and sleepy at school tomorrow
  • 🤯 find it harder to focus and to remember
  • 😠 grumpy and easily upset
  • 🤧 catch colds more easily

Children your age need 9 to 12 hours of sleep every night. Numo will be right here tomorrow!