← Data representation

How many patterns?

Each extra bit doubles the number of patterns: n bits make 2ⁿ patterns. One pattern is 0, so the largest number is 2ⁿ − 1: four bits hold 0 to 15, eight bits (a byte) hold 0 to 255. Count one past the largest and the bits overflow back to 0.

Colour values in a program stop at 255, and old game scores wrapped round to 0. Both come from the same rule about bits.

In Bits and binary numbers, each card was worth double the card on its right. Now the question is how many different numbers a set of cards can show, and what happens when you run out.

PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.

The biggest number

You have four cards, worth 8, 4, 2 and 1. What is the **biggest** number they can show?

TryTry it on the board and compare the result with your prediction.

Try: count up

Was your prediction right? Watch the 1 card as you count: it flips every time.

Try it yourselfYour edits are saved in this browser.

Press + 1 to count up until every card is face up. What number is it?

Use the board. This ticks when you get there.

InvestigateWork out why it happens, one step at a time.

Worked example: count the patterns

Worked exampleBefore each step, say what you think comes next.
  1. 1111=8+4+2+1=151111 = 8 + 4 + 2 + 1 = 15All cards face up is the biggest number.

Now try five bits.

What is the biggest number **five** bits can show?

Sam works out how many numbers 4 bits can show. Click the line where the working first goes wrong.

How many different patterns can **three** bits make?

ModifyChange the problem on purpose and see what happens.

Vary: one change at a time

Keep doubling: 1, 3, 7, 15, 31, 63, 127. Which is the first that reaches 100?

Try it yourselfYour edits are saved in this browser.

The board shows 1111, which is 15. Press + 1 once. What happens to the cards?

Use the board. This ticks when you get there.

Press Add a card. What is the new card worth? Make the biggest number five cards can show.

Use the board. This ticks when you get there.

Add one more card and make the biggest number six cards can show.

Use the board. This ticks when you get there.

Eight bits are called a **byte**. What is the biggest number a byte can hold?

What is the **fewest** bits that can hold the number 100?

PractiseA few on your own, to check you have it.

Patterns and limits

How many different patterns can **ten** bits make?

An old game stores the score in one byte. The score is 255 and the player scores 1 more point. What does the score show?

In many programs, the amount of red in a colour goes from 0 to 255. How many bits store it?

What is the biggest number **three** bits can show?

Review: what number is **10101** in binary?

MakeMake your own problem using what you have learned. Expect a few tries; that is normal.

Enough bits

Then: how many more students could join before you need a seventh card?

Try it yourselfYour edits are saved in this browser.
Need a hint?

How big a number must the cards show? Add cards until they can show it.

Another hint

Five cards stop at 31. Is that enough for 39?

Another hint

Six cards: 32 + 4 + 2 + 1.

A school gives each student in a group an ID number from 0 to 39. Use the fewest cards that can show 39, then set them to 39.

Use the board. This ticks when you get there.

For teachers

Students count up on binary cards to find that n bits make 2ⁿ patterns and hold 0 to 2ⁿ − 1, see a count overflow, and choose how many bits a number needs (AC9TDI8K04). About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Do the Try and Vary boards yourself first. Students need Bits and binary numbers (reading binary) and powers of 2 from maths.

The one idea: each extra bit doubles the number of patterns, so nn bits make 2n2^n patterns, and because one pattern is 0, the largest number is 2n−12^n - 1. Overflow is what happens when you count past it.

Real examples worth a minute: colour values 0 to 255 (one byte each); the micro:bit LED brightness 0 to 255; game scores and counters that wrapped round. Students who have done Arcade or micro:bit can look for 255 limits in the blocks.

Running the lesson

  1. Predict: students who chose 16 counted the patterns but forgot 0; 4 counted the cards.
  2. Try: ask how many presses it took to get from 0 to 1111, and how many patterns that makes.
  3. Worked example: pause before line 3 and ask why we multiply, not add.
  4. Vary: before Add a card, ask students to predict the new card's value and the new biggest number.
  5. Make: have students say the range first (0 to 39), then the bits.

The hard part (on purpose)

Forgetting that one pattern is 0, so saying 4 bits go up to 16. Ask "what do the cards show when they are all face down?" every time a largest number comes up.

When students get stuck

Stretch and support

Stretch: How many bits would you need to give every person on Earth (about 8 billion) a different number? (33: 2³² is about 4.3 billion, 2³³ about 8.6 billion.)

Support: Keep a doubling table beside the board: bits 1 to 8, patterns 2 to 256, biggest 1 to 255.

Where it leads

Builds on: the data as numbers lessons. Colour amounts (0 to 255) are one byte each, and 16-bit audio has 2¹⁶ = 65 536 levels: ask students to explain both now.

Where it leads: data sizes (bytes, kilobytes) and, in Years 9–10, compression.

Sources

What each step is for

Now you can
Next lesson7. Why binary: logic gatesA switch has two states that are easy to tell apart: off (0) and on (1). Wire two switches in a line and the lamp lights only when both are on: an AND gate. Side by side, either one will do: an OR gate. Gates like these, made of tiny electronic switches, combine bits to do every calculation, which is why computers are built on binary.