← ACARA Digital Technologies Years 7–8

Working out how many bits a number needs

Find the smallest number of bits n whose largest value, 2^n - 1, is at least your number. Example: 20 is too big for 4 bits (max 15), so it needs 5 bits (max 31).

Understanding Working out how many bits a number needs in ACARA Digital Technologies Years 7–8

What it does: The largest 4-bit value is 15. Checking 20 <= 15 gives False, so 4 bits is too small for 20. 4 bits only reaches 15, but 5 bits reaches 31, which is at least 25. So 5 is the smallest bit length that works. 4 bits can hold 2^4 - 1 = 15 at most. 20 is bigger than 15, so 4 bits is too small. We only need the largest value to be big enough. It does not have to match the number exactly. 5 bits give 2^5 = 32 values, but they start at 0. So the largest is 2^5 - 1 = 31.

Common mistakes: The largest value n bits can hold is 2^n - 1, not 2^n. With 4 bits the largest value is 15, so the line should be max_value = 2**4 - 1. While the largest value is still too small, we need MORE bits, so bits must go up by 1. Subtracting would never reach 5 bits for 25. It should be bits = bits + 1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 173–188) and word search (Modules 153–188).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Can the number 20 be stored in 4 bits?
No, 4 bits only go up to 15Yes, 4 bits go up to 20
Matches
Largest 4-bit number = 2^4 = 16
↓
Forgot to subtract 1. Counting starts at 0, so the largest 4-bit number is 2^4 - 1 = 15.
Applying
Meanings
Term
2^n - 1 >= number
Meaning
Find the smallest number of bits n whose largest value, 2^n - 1, is at least your number. Example: 20 is too big for 4 bits (max 15), so it needs 5 bits (max 31).
Practice
number ← 20
Testing
Gaps
4 bits: 2^4 - 1 =
Check Answer
Spots
1max_value = 2**4
2number = 20

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Rhinoceros' badge — Thick-Skinned Coder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Can the number 20 be stored in 4 bits?
A. No, 4 bits only go up to 15 ✓
B. Yes, 4 bits go up to 20
4 bits can hold 2^4 - 1 = 15 at most. 20 is bigger than 15, so 4 bits is too small.
2. How many bits does the number 25 need?
A. 4 bits (largest value 15)
B. 5 bits (largest value 31) ✓
4 bits stops at 15, which is less than 25. 5 bits holds up to 31, so 5 bits is the smallest that works.
3. Which rule finds a big enough bit length for a number?
A. Pick the smallest n where 2^n - 1 is at least the number ✓
B. Pick the n where 2^n is exactly equal to the number
We only need the largest value to be big enough. It does not have to match the number exactly.
4. What is the largest number 5 bits can hold?
A. 31 ✓
B. 32
5 bits give 2^5 = 32 values, but they start at 0. So the largest is 2^5 - 1 = 31.
5. You want to store the number 9. Which bit length is the smallest that is big enough?
A. 3 bits, because 9 is close to 7
B. 4 bits, because 3 bits only reach 7 ✓
3 bits hold up to 7, which is less than 9. 4 bits hold up to 15, so 4 bits is the smallest choice.

Match the Pairs

2^4 - 1 = 15 → 4 bits can hold at most 15, so 20 is too big for 4 bits
2^5 - 1 = 31 → 5 bits can hold up to 31, so 25 fits in 5 bits
To test if a number fits in a bit length, compare it with the largest value for that length → 20 <= 2^4 - 1 is False
Choose the smallest bit length n whose largest value is at least your number → n = 5 because 2^5 - 1 >= 25
Largest 4-bit number = 2^4 = 16 → Forgot to subtract 1. Counting starts at 0, so the largest 4-bit number is 2^4 - 1 = 15.
31 needs 6 bits because 31 is not bigger than 2^5 - 1 → 31 equals the largest 5-bit value (2^5 - 1 = 31), so it fits in 5 bits. A number only needs more bits if it is bigger than the maximum.

Key Term

2^n - 1 >= number
Find the smallest number of bits n whose largest value, 2^n - 1, is at least your number. Example: 20 is too big for 4 bits (max 15), so it needs 5 bits (max 31).

Fill in the Blanks

1. 4 bits: 2^4 - 1 = 15
Hint: Type the largest value that 4 bits can hold.
2. 2^5 - 1 = 31, which is at least 25
Hint: Type the number of bits that gives a largest value of 31.
3. Is 2^5 - 1 >= 25? Yes, so 5 bits is enough
Hint: Type the operator that means 'greater than or equal to'.
4. n = 1 WHILE 2^n - 1 < 20: n = n + 1
Hint: Type the expression that adds one more bit to n.
5. 9: 2^3 - 1 = 7 is too small, so use 2^4 - 1
Hint: Type the next bit length to try after 3 bits was too small.

Spot the Error

Question 1
A max_value = 2**4
B number = 20
C if number > max_value:
D print('Needs more than 4')
Line A — The largest value n bits can hold is 2^n - 1, not 2^n. With 4 bits the largest value is 15, so the line should be max_value = 2**4 - 1.
Question 2
A number = 25
B bits = 1
C while 2**bits - 1 < number:
D bits = bits - 1
E print(bits)
Line D — While the largest value is still too small, we need MORE bits, so bits must go up by 1. Subtracting would never reach 5 bits for 25. It should be bits = bits + 1.
Question 3
A number = 25
B bits = 5
C largest = 2*bits - 1
D print(largest >= number)
Line C — Each extra bit doubles the number of values, so we need a power: 2**bits. Using 2*bits gives 9 instead of 31. It should be largest = 2**bits - 1.
Question 4
A number = 20
B largest_4 = 2**3 - 1
C print(number <= largest_4)
Line B — The variable is for 4 bits, so the power must be 4: 2**4 - 1 = 15. Using 2**3 - 1 gives the largest 3-bit value, which is 7.
Question 5
A largest ← 5^2 - 1
B IF 25 <= largest THEN
C OUTPUT '5 bits is enough'
D ENDIF
Line A — The base must be 2 and the number of bits is the power. 5^2 - 1 is 24, but 5 bits hold up to 2^5 - 1 = 31. It should be largest ← 2^5 - 1.

Student with a class code? Join your class →