Wimzee Cambridge Academy
← All Revision Notes← IGCSE Computer Science

Data Representation

Revision Notes — IGCSE
CAIE IGCSE Computer Science (0478) • Topic 1 of 10 • Paper 1 & Paper 2
Mastered: 0 / 2

1.1 Number Systems

A computer stores everything as binary because a circuit has two reliable states: on (1) and off (0). Every number, character, picture and sound is converted into a pattern of bits before the computer can process it.

TermMeaning
BitA single binary digit, 0 or 1
Nibble4 bits
Byte8 bits
Kilobyte (KB)1000 bytes (1024 bytes when using KiB)
Megabyte (MB)1000 KB
Gigabyte (GB)1000 MB
Terabyte (TB)1000 GB

Denary to binary (and back)

Use the place values 128, 64, 32, 16, 8, 4, 2, 1 for an 8-bit byte. To convert denary to binary, subtract the largest place value that fits and repeat, writing 1 where you used a value and 0 where you did not.

Denary 202 -> 128 + 64 + 8 + 2 -> 11001010 Check: 128 + 64 + 8 + 2 = 202 (correct)

To convert binary to denary, add the place values wherever a 1 appears. To convert binary to hexadecimal, split the byte into two nibbles and convert each nibble separately (1011 0111 → B7). Hexadecimal is used because it is far shorter than binary for humans to read and write, and converting between hex and binary is trivial.

Binary addition and overflow

Add column by column from the right using four rules: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).

0 1 1 0 1 1 0 1 (109) + 0 0 1 1 0 1 1 0 ( 54) ----------------- 1 0 1 0 0 0 1 1 (163)

Overflow happens when the result of an addition is too large to be stored in the number of bits available — for example, adding two 8-bit numbers and getting a 9-bit answer. The extra carry bit is lost, so the stored answer is wrong. The computer must detect the overflow so it can report an error.

Logical binary shifts

A logical left shift moves every bit one place to the left and puts a 0 in the empty right-hand position; this multiplies the value by 2. A logical right shift moves bits right and puts a 0 in the empty left-hand position, dividing by 2. Bits shifted off the end are lost.

0000 1010 (10) left shift -> 0001 0100 (20) 0000 1010 (10) right shift -> 0000 0101 ( 5)

Two's complement (negative numbers)

In an 8-bit two's complement system the leftmost bit has a place value of −128. To write a negative number, write the positive value in binary, invert every bit, then add 1.

+5 = 0000 0101 invert = 1111 1010 +1 = 1111 1011 = -5 Range of 8-bit two's complement: -128 to +127

1.2 Text, Sound and Images

Character sets

Character setDescription
ASCII7-bit code giving 128 characters; extended ASCII uses 8 bits for 256 characters. Covers English letters, digits and punctuation only.
UnicodeUses up to 4 bytes per character and can represent virtually every language, symbol and emoji. Needed for global communication and so that one file works on any computer.

Representing sound

A microphone converts the analogue sound wave into an electrical signal, which is sampled at regular intervals. Each sample is stored as a binary number.

Sound file size (bits) = sample rate x sample resolution x duration (s) x channels Example: 44 100 x 16 x 30 x 2 = 42 336 000 bits = 5 292 000 bytes (~5.3 MB)

Representing images

A bitmap image is a grid of pixels. Each pixel stores a binary value that refers to a colour in a palette.

Image file size (bits) = width in pixels x height in pixels x colour depth Example: 800 x 600 x 24 = 11 520 000 bits = 1 440 000 bytes (~1.44 MB)

1.3 Data Storage

Storage typeHow it worksTypical use
Magnetic (HDD)Magnetised areas on a spinning platter read by a moving headLarge capacity, low cost per GB; desktops, servers, backups
Optical (CD/DVD/Blu-ray)A laser burns pits and lands; a laser reads the reflectionsMusic, films, software distribution; cheap but low capacity
Solid state (SSD, flash, SD card)Floating-gate transistors hold charge; no moving partsLaptops, phones, cameras; fast, silent, shock resistant, more expensive per GB

Secondary storage is needed because RAM is volatile and limited: it stores the operating system, applications, user files and backups permanently. Virtual memory is an area of secondary storage used as an extension of RAM when RAM is full; pages of data are swapped between RAM and disk, which is much slower than RAM.

1.4 Compression

TypeHow it worksEffect
LossyPermanently removes data the human eye or ear is unlikely to notice (MP3, JPEG)Much smaller files, but quality is reduced and cannot be restored
LosslessStores the data more efficiently so the original can be rebuilt exactly (PNG, FLAC, ZIP)Smaller files with no loss of quality, but less reduction than lossy

Run-length encoding (RLE) is a lossless method that stores a repeated value once, followed by how many times it occurs: WWWWWBBBWW becomes 5W3B2W. It works best on data with long runs of identical values, such as simple logos.

Exam trap

File size questions are easy marks — but only if you keep the units straight. Multiply first, then divide by 8 to go from bits to bytes, and by 1000 (or 1024) to reach KB. Always state the unit.

Five-minute drill

  1. Convert 173 to 8-bit binary and to hexadecimal.
  2. Add 0110 1100 and 0011 0110. State whether overflow occurs.
  3. Left shift 0000 0110 twice. What is the denary result?
  4. A 4-minute stereo recording is sampled at 20 kHz with a resolution of 8 bits. Calculate the file size in MB.
  5. Explain why Unicode is preferred to ASCII for a website used worldwide.
Exam practice 1[4]

A photograph is 4000 pixels wide and 3000 pixels high and uses a colour depth of 24 bits. (a) Calculate the file size in megabytes. Show your working. (b) The photograph is saved as a JPEG instead of a PNG. Explain one effect this has on the file.

Mark scheme
  • (a) 4000 × 3000 × 24 = 288 000 000 bits (1); ÷ 8 = 36 000 000 bytes (1); ÷ 1 000 000 = 36 MB (1).
  • (b) JPEG uses lossy compression, so data is permanently removed (1); the file is much smaller but quality is reduced and cannot be restored (1).
Exam practice 2[5]

A computer stores the denary value −6 using 8-bit two's complement. (a) Write the binary representation. (b) State the range of values that can be stored in 8 bits using two's complement. (c) Explain what is meant by overflow.

Mark scheme
  • (a) +6 = 0000 0110; invert = 1111 1001; add 1 = 1111 1010 (2 marks for the answer, 1 for method).
  • (b) −128 to +127 (1).
  • (c) The result of a calculation is larger than the maximum value that can be held in the available number of bits (1), so the most significant bit is lost and the stored answer is incorrect (1).

Quick Reference

8-bit place values: 128 64 32 16 8 4 2 1 Left shift = x2, right shift = /2, empty bit filled with 0 Two's complement: invert bits, add 1; MSB = -128 Image size = width x height x colour depth (bits) Sound size = rate x resolution x seconds x channels (bits) Lossy = data removed for ever; lossless = original rebuilt exactly