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.
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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
2^n - 1 >= numberFill in the Blanks
Spot the Error
Student with a class code? Join your class →