← Back to subjects
⭐ 0
AQA A-level Computer Science (7517) Β· Fundamentals of data representation
Mini-Lesson

Fundamentals of data representation

This mini-lesson covers AQA 4.5 β€” Fundamentals of data representation, the most calculation-heavy topic on the course. Every number below is one you must be able to work out by hand, in an exam, without a calculator.

  • Number bases β€” binary, denary, hexadecimal
  • Two's complement and binary fractions
  • Floating point, normalisation and rounding error
  • ASCII, Unicode and error checking
  • Images and sound β€” file-size calculations
  • Compression and encryption

Work through each screen, answer the questions as you go (some are recall, some are calculations you must actually work out) and collect ⭐ stars. Press Start when you're ready.

4.5 Β· Number bases

Binary, denary and hexadecimal

A number base is just a set of column values. Denary uses powers of 10, binary powers of 2, hexadecimal powers of 16 (digits 0–9 then A=10, B=11, C=12, D=13, E=14, F=15).

128 64 32 16 8 4 2 1 1 1 0 1 1 0 0 1 = 217

Denary β†’ binary: work left to right through the column headings, taking each one you can. 217 βˆ’ 128 = 89; 89 βˆ’ 64 = 25; 32 is too big (0); 25 βˆ’ 16 = 9; 9 βˆ’ 8 = 1; 4 and 2 too big; 1 βˆ’ 1 = 0. Result 11011001.

Binary β†’ hex: split into nibbles of 4 bits and convert each: 1101 = 13 = D, 1001 = 9. So 11011001 = D9. Check: D9 = 13 Γ— 16 + 9 = 208 + 9 = 217 βœ“

Why hex exists: it is human shorthand for binary. One hex digit = exactly 4 bits, so a byte is always 2 hex digits. It is shorter, far less error-prone to read, and maps back to binary with no arithmetic. Memory addresses, colour codes (#FF8800) and MAC addresses are all written in hex.

Units: AQA uses decimal prefixes β€” 1 kB = 10Β³ bytes, 1 MB = 10⁢, 1 GB = 10⁹, 1 TB = 10ΒΉΒ². The binary prefixes are separate: 1 KiB = 2¹⁰ = 1024 bytes, 1 MiB = 2²⁰ bytes.

Calculate

Your turn β€” denary to binary

1Convert the denary number 217 to 8-bit binary.
Hint: Column headings 128 64 32 16 8 4 2 1. Subtract each one you can: 217 βˆ’ 128 = 89, 89 βˆ’ 64 = 25, and keep going.
Calculate

Your turn β€” binary to hex

2Convert the binary number 11011001 to hexadecimal.
Hint: Split into two nibbles: 1101 and 1001. Convert each nibble to a single hex digit.
4.5 Β· Signed binary

Two's complement

To store negative numbers, the most significant bit is given a negative weight. In 8 bits:

-128 64 32 16 8 4 2 1 1 1 1 0 1 1 0 0 = -128 + 64 + 32 + 8 + 4 = -20

To negate a number: write the positive value in binary, flip every bit, then add 1.

+20 = 0001 0100 flip = 1110 1011 add 1 = 1110 1100 = -20 βœ“

Range in n bits: from βˆ’2ⁿ⁻¹ to +2ⁿ⁻¹ βˆ’ 1. For 8 bits that is βˆ’128 to +127 β€” note the asymmetry: there is one more negative value than positive, because 0 uses up a positive-looking pattern.

Why two's complement won: there is only one representation of zero (sign-and-magnitude has +0 and βˆ’0), and subtraction becomes addition: A βˆ’ B is computed as A + (βˆ’B) using the ordinary adder circuit. One piece of hardware does both.

Calculate

Your turn β€” negate in two's complement

3Represent βˆ’20 as an 8-bit two's complement binary number.
Hint: Start from +20 = 00010100. Flip every bit, then add 1.
Calculate

Your turn β€” two's complement to denary

4What denary value does the 8-bit two's complement number 10110110 represent?
Hint: The leading bit is worth βˆ’128. Column values: βˆ’128, 64, 32, 16, 8, 4, 2, 1. Add up the columns with a 1 in them.
4.5 Β· Fractions

Fixed point binary fractions

Put a binary point in a fixed position and the columns to its right carry negative powers of 2:

8 4 2 1 . 1/2 1/4 1/8 1/16 0 1 1 0 . 1 0 1 0 = 4 + 2 = 6 . 0.5 + 0.125 = 0.625 = 6.625

With a fixed point, the number of bits before and after the point is decided in advance. That fixes both the range and the precision β€” and you cannot trade one for the other.

The fatal flaw: many everyday denary fractions have no exact binary representation. 0.1 in binary is 0.0001100110011… recurring forever. Truncating it introduces a tiny error β€” which is precisely why 0.1 + 0.2 does not equal 0.3 in most languages, and why money is stored in whole pence.

4.5 Β· Floating point

Floating point and normalisation

Floating point stores a number in two parts, in the form:

value = mantissa Γ— 2exponentboth parts held in two's complement

The mantissa carries the significant digits (and so sets the precision); the exponent says where the binary point goes (and so sets the range). For a fixed total word length, giving bits to one takes them from the other β€” that is the central trade-off.

Normalisation squeezes the maximum precision out of the mantissa by removing leading redundant bits:

  • a positive normalised mantissa begins 0.1…
  • a negative normalised mantissa begins 1.0…

In both cases the first two bits differ. The exponent is adjusted to compensate for each shift, so the value is unchanged.

Worked example

Mantissa 0.1101000, exponent 0011 (= +3).

Shift the point 3 places right: 0110.1000

= 4 + 2 = 6, plus 0.5 β†’ 6.5

Calculate

Your turn β€” floating point to denary

5A number is held with a 7-bit mantissa and a 4-bit exponent, both in two's complement.
Mantissa = 0.1101000   Exponent = 0011
What is its value in denary?
Hint: The exponent 0011 is +3, so move the binary point 3 places to the right: 0110.1000.
4.5 Β· Errors

Rounding errors, range and precision

Because a mantissa has finitely many bits, most reals can only be stored approximately. The gap between the true value and the stored one is a rounding error β€” and errors accumulate across millions of operations.

absolute error = |stored βˆ’ true|relative error = absolute error Γ· true value (often as a %)

The relative error is usually the meaningful one: an absolute error of 1 km is catastrophic in surveying and irrelevant in astronomy.

More bits in the…Effect
mantissagreater precision (finer detail), smaller range
exponentgreater range (bigger and smaller magnitudes), coarser precision

The bug that costs lives: in 1991 a Patriot missile battery tracked time as a 24-bit fixed-point count of tenths of a second. 0.1 has no exact binary form, so after 100 hours of running, the accumulated rounding error was about a third of a second β€” enough to misplace an incoming missile by half a kilometre. 28 people died. Rounding error is not an academic curiosity.

Quick check

Range and precision

?A 16-bit floating-point format is redesigned to give more bits to the exponent and fewer to the mantissa. What is the effect?
4.5 Β· Coding systems

Character sets and error checking

ASCII uses 7 bits for 128 characters (often stored in a byte with the top bit spare). It cannot represent Greek, Arabic, Chinese or an emoji. Unicode was created to fix exactly that: it assigns a unique code point to every character in every script, needing 16 bits or more per character.

Data in transit gets corrupted. Four standard defences:

  • Parity bit β€” one extra bit set so the total number of 1s is even (even parity) or odd. It detects any single-bit error but cannot say where, and misses any two flipped bits.
  • Majority voting β€” send each bit three times and take the most common value. It corrects as well as detects, at triple the bandwidth.
  • Checksum β€” an arithmetic total sent with the data and recomputed on arrival. Detects, but does not locate or correct.
  • Check digit β€” a digit computed from the others and appended (ISBNs, barcodes). Catches typing and transcription errors.

Detect vs correct: parity, checksums and check digits only detect β€” the data must be re-sent. Majority voting and other error-correcting codes can repair the data in place. That matters enormously for a spacecraft that cannot simply be asked to re-transmit.

Quick check

Parity

?A system uses even parity. The byte 1011011 is to be transmitted with a parity bit added. What is the parity bit, and what is the weakness of the scheme?
4.5 Β· Images & sound

Bitmapped images and sampled sound

A bitmapped image is a grid of pixels. Resolution = pixels across Γ— down. Colour depth = bits per pixel, giving 2ⁿ possible colours (24-bit gives 2²⁴ β‰ˆ 16.7 million).

file size (bits) = width Γ— height Γ— colour depth+ metadata (dimensions, colour depth, format β€” needed to reconstruct the image)
Worked example β€” image

800 Γ— 600 pixels at 24-bit colour

= 480 000 pixels Γ— 24 bits = 11 520 000 bits

= 11 520 000 Γ· 8 = 1 440 000 bytes (β‰ˆ 1.44 MB)

A vector image instead stores objects (line, circle, fill) with properties. It scales to any size with no loss of quality and is usually far smaller β€” but it is hopeless for a photograph.

Sound is a continuous analogue wave, sampled by an ADC. Sampling rate (Hz) = samples per second; sample resolution = bits per sample.

file size (bits) = rate Γ— resolution Γ— seconds Γ— channels
Worked example β€” sound

10 s of mono at 44 100 Hz, 16-bit

= 44 100 Γ— 16 Γ— 10 = 7 056 000 bits

= 882 000 bytes

Nyquist: to reproduce a frequency f you must sample at at least 2f. Human hearing tops out near 20 kHz β€” which is exactly why CD audio samples at 44.1 kHz. MIDI stores no sound at all: it stores instructions (note, pitch, velocity, duration), so it is tiny and endlessly editable, but it can never capture a real singer.

Calculate

Your turn β€” image file size

6An uncompressed bitmap is 800 Γ— 600 pixels with a colour depth of 24 bits. Ignoring metadata, what is its size in bytes?
bytes
Hint: width Γ— height Γ— colour depth gives bits. Then divide by 8 to get bytes.
4.5 Β· Compression

Compression

Lossless compression discards nothing: the original is restored bit for bit. Essential for text, code and executables β€” a program with a few bits missing is not a program.

  • Run-length encoding (RLE) β€” replace runs of identical values with (value, count). AAAAABBB β†’ A5B3. Excellent on large flat areas; it can enlarge a file with no runs, since every single character becomes a pair.
  • Dictionary-based (LZW) β€” build a dictionary of repeated sequences and send short index codes instead. The dictionary is rebuilt by the decoder, so it need not always be transmitted.

Lossy compression permanently throws data away, exploiting the limits of human perception β€” MP3 removes frequencies you cannot hear, JPEG discards fine colour detail your eye ignores. It achieves far higher compression ratios, and the discarded data is gone forever.

Exam trap: RLE is lossless, even though it is used on images. Being used on media does not make a method lossy β€” what matters is whether the original can be reconstructed exactly.

4.5 Β· Encryption

Encryption and hashing

Caesar cipher β€” shift each letter by a fixed amount. Trivially broken: there are only 25 keys, and frequency analysis cracks it instantly because E remains the commonest letter.

Vernam cipher (one-time pad) β€” XOR the plaintext with a truly random key that is at least as long as the message and is used exactly once. It is the only cipher that is mathematically unbreakable: every possible plaintext of that length is equally likely. Decryption is the same operation again, because XOR is its own inverse.

plaintext 1 0 1 1 0 1 1 0 key 0 1 1 0 1 1 0 1 XOR 1 1 0 1 1 0 1 1 ← ciphertext XOR key 1 0 1 1 0 1 1 0 ← plaintext back again
SymmetricAsymmetric
One shared key encrypts and decryptsA public key encrypts; only the matching private key decrypts
Fast β€” good for bulk dataSlow β€” used to exchange a symmetric key, and for digital signatures
The problem: how do you share the key securely?Solves key distribution: the public key can be shouted from the rooftops

Hashing is not encryption. A hash is one-way β€” it is designed to be impossible to reverse. Passwords are stored as hashes so that a stolen database reveals nothing usable. Encryption is designed to be reversed by whoever holds the key; hashing is designed never to be reversed at all.

Quick check

The Vernam cipher

?Why is the Vernam cipher (one-time pad) mathematically unbreakable, while the Caesar cipher is trivial to break?
Quick check

Compression

?A software company must compress the installer for its application before distribution. Which type of compression must it use, and why?
Sort it

Sort the techniques

Tap a technique, then tap the group it belongs to.

🧊 Lossless compression

βœ‚οΈ Lossy compression

πŸ” Not compression

Match it

Match the description to the term

Tap an item on the left, then its partner on the right.

Description
Term
Recap

The big ideas to know

Bases: 217 = 11011001 = D9 · one hex digit = 4 bits · 1 kB = 10³ B, 1 KiB = 2¹⁰ B

Two's complement: MSB is negative Β· negate = flip and add 1 Β· 8-bit range βˆ’128 to +127 Β· subtraction becomes addition

Fractions: columns right of the point are Β½, ΒΌ, ⅛… Β· 0110.1010 = 6.625 Β· 0.1 has no exact binary form

Floating point: mantissa Γ— 2^exponent Β· normalise: positive starts 0.1, negative starts 1.0 Β· mantissa = precision, exponent = range

Coding & errors: ASCII 7-bit vs Unicode Β· parity/checksum/check digit detect Β· majority voting corrects

Images & sound: size = w Γ— h Γ— depth Β· size = rate Γ— resolution Γ— time Γ— channels Β· Nyquist: sample at 2f

Compression: lossless (RLE, LZW) recovers exactly Β· lossy (MP3, JPEG) discards permanently

Encryption: Caesar (weak) Β· Vernam (unbreakable, one-time pad) Β· symmetric = fast, asymmetric = solves key exchange Β· hashing is one-way

That is the whole of AQA 4.5. Press Finish to see your score.

πŸ†

Mini-lesson complete!

⭐⭐⭐

You've worked through Fundamentals of data representation for AQA A-level Computer Science (7517). πŸŽ‰

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