← Back to Tools

Data Representation – Part 2

Binary addition, overflow, binary subtraction, binary shifts and hexadecimal. Read the Learn notes, then take the 30-question challenge — drag the number tiles into place, beat the clock, and find out which robot you are.

Topic 1

Binary Addition

Add binary numbers column by column from the right, just like normal addition. There are four rules:

0 + 0 = 0 1 + 0 = 1 1 + 1 = 10 (write 0, carry 1) 1 + 1 + 1 = 11 (write 1, carry 1)
1 1 ← carries 0 1 1 0 (6) + 0 1 1 1 (7) ------- 1 1 0 1 (13)

Tip: check your answer by converting to denary — 6 + 7 = 13 ✓

Topic 1b

Overflow Errors

Sometimes adding two binary numbers gives an answer with an extra digit that won’t fit in the number of bits available. This is an overflow error.

0 1 (1) + 1 0 (2) --- 1 1 (3) ✓ fits
1 1 (3) + 0 1 (1) ----- 1 0 0 ✗ needs 3 bits!

An overflow might make a program crash, or the extra digit is simply lost — giving a wrong answer (here 3 + 1 would come out as 00 = 0!).

Topic 2

Binary Subtraction

Work from the right. When you take 1 from 0 you must borrow from the next column to the left (that column goes down by 1).

0 − 0 = 0 1 − 0 = 1 1 − 1 = 0 0 − 1 = 1 (borrow 1)
0 ← borrowed from 1 1 0 0 (12) − 0 0 1 1 (3) ------- 1 0 0 1 (9)

A borrowed 1 is worth 2 in the column it moves into (10 in binary). Check: 12 − 3 = 9 ✓

Topic 3

Binary Shift

A binary shift moves every bit left or right by a number of places. The gaps are filled with 0s and bits pushed off the end are lost.

Left 1 = ×2Left 2 = ×4Left 3 = ×8 Right 1 = ÷2Right 2 = ÷4Right 3 = ÷8

Try it: click bits to change them, then shift.

Denary 4100101001 is the example from the slides
Topic 4

Hexadecimal

Hex is base 16. It uses 0–9 then A–F for 10–15, so one hex digit = one nibble (4 bits).

Topic 5

Binary ↔ Hex: the nibble method

Break the binary into nibbles (groups of 4 bits). Work out each nibble using 8 4 2 1, then turn each into one hex digit. It works in reverse too: each hex digit becomes 4 bits.

Try it: click the bits.

Left nibble 0 → 0Right nibble 0 → 0
Hex 00Denary 0
Hex → denary: (first digit × 16) + second digit. e.g. B4 = 11×16 + 4 = 180.