← Back to GCSE guidesCodeBash GCSE Computer Science← PreviousNext →
Data Representation

Number Representation

Computers only ever store 1s and 0s. Everything else, whole numbers, negative numbers, letters, images, sound, is just an agreed way of interpreting patterns of bits. This page covers the foundation: how binary and denary relate, what happens when a number gets too big to fit, and how negative numbers are represented at all.

Section 2

Binary and denary: two names for the same value

Click the bits to toggle them on and off. Each column is worth a power of 2, and the denary total updates live. This is an 8-bit number, so it can represent 0 to 255.

0
Click any bit to toggle it. Watch which power of 2 it adds or removes from the total.

Try a value

Exam tips

  • Each bit position is worth double the one to its right: 128, 64, 32, 16, 8, 4, 2, 1 for 8 bits.
  • To convert binary to denary, add up the place values of every bit that's a 1.
  • An 8-bit number can represent 2⁸ = 256 different values: 0 to 255 (unsigned).
  • A common exam mistake: writing the place values in the wrong order. Always start from the left with the largest value.
Section 3

Hexadecimal: a shorthand for binary

Hex digits run 0-9 then A-F, representing 0 to 15. The reason hex is genuinely useful (not just a different counting system) is that each hex digit maps onto exactly 4 bits, no maths required, just direct substitution. Toggle the bits below and watch each 4-bit group turn into a single hex digit.

Click any bit to toggle it. Watch which nibble (group of 4 bits) it belongs to, and how that nibble's hex digit changes.

Try a value

Hex digit lookup

Exam tips

  • Hex to binary: replace each hex digit with its 4-bit equivalent directly, no calculation needed.
  • Hex to denary: multiply each digit by 16 raised to its position (16⁰, 16¹, ...) and add up, exactly like place value in denary or binary, just base 16.
  • Two hex digits represent exactly one byte (8 bits), which is why hex shows up constantly: colour codes like #FF5733, memory addresses, MAC addresses.
  • Common mix-up: hex "10" is denary 16, not ten. Always be clear which base you're reading.
Section 4

Denary to binary: repeated division

This is the method you'd use with pen and paper: keep dividing by 2, and read the remainders from bottom to top. Pick a number and step through it.

Division steps

Dividend÷ 2Remainder

Convert

Section 5

Binary addition

Add binary numbers exactly like column addition in denary, right to left, carrying into the next column whenever a column totals 2 or more.

Controls

Exam tips

  • 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).
  • Always work right to left, exactly like denary column addition.
Section 6

What about adding three numbers at once?

Exactly the same idea, right to left, carrying whenever a column totals 2 or more. The one genuine difference: with three operands, a single column can now carry a value of 2, not just 1, since three 1s in one column already sum to 3.

Try it

Why this matters

Real processors almost never add three numbers in one go for exactly this reason: managing a carry that can be bigger than 1 is more complex circuitry. In practice, hardware (and most algorithms) add two numbers at a time: total = a + b, then total = total + c, reusing the simple 2-operand adder twice. Try it yourself: 45 + 30 = 75, then 75 + 15 = 90, matches the three-way total exactly.

Section 7

Overflow: proof, not just a rule

50 + 30 = 80 fits comfortably in 8 bits. But 200 + 100 = 300, and an 8-bit register can only hold 0 to 255. Watch what actually happens when the true answer doesn't fit.

Try it

Exam tips

  • Overflow happens when a calculation's true result needs more bits than the register has available.
  • The register doesn't raise an alarm by itself, it silently keeps only the bits that fit and discards the final carry. That's why 200 + 100 quietly becomes 44 instead of 300.
  • This is exactly why choosing an appropriate number of bits (or data type) for a variable matters in real programs.
Section 8

Two's complement: representing negative numbers

Binary has no minus sign. Two's complement solves this with a trick: to negate a number, flip every bit, then add 1. Pick a value and watch it happen.

Step 1: start with the positive value

Step 2: flip every bit

Step 3: add 1

Negate which value?

Proof: does it actually work?

If two's complement is genuinely correct, adding a number to its own negative using completely ordinary binary addition should give zero. No special subtraction circuit needed, just the same adder from Section 4.

Controls

Exam tips

  • To negate: invert every bit (0↔1), then add 1 to the result.
  • The leftmost bit acts as a sign indicator: 0 means positive, 1 means negative, but don't just call it a "sign bit" and stop there, it still contributes its normal place value to the calculation.
  • 8-bit two's complement range: −128 to +127. Notice it's not symmetric, there's one more negative value than positive.
  • The entire point of two's complement: normal binary addition automatically handles subtraction, no separate hardware needed.
Section 9

Check your understanding