CS1 — Binary and Positive Integers
- I can explain why computers store all data as binary
- I can convert a positive denary integer to binary and back again
- I can state and apply the formula for the range of positive integers storable in a given number of bits
- I can convert any positive integer up to 255 to 8-bit binary without a calculator
- I can convert any 8-bit binary number to denary
- I can state that n bits can represent 2ⁿ values, from 0 to 2ⁿ−1
- I can work out the minimum number of bits needed to store a given range of values
Key vocabulary
Why binary?
Digital computers are built from millions — often billions — of tiny electronic switches called transistors. A switch can only ever be in one of two states: on or off. That gives us exactly two symbols to work with, which we represent as 1 (on) and 0 (off).
This is why all data handled by a computer — whether it is a number, a letter, a photograph, or a line of program code — is ultimately stored as a sequence of 1s and 0s. We call this sequence binary. Each individual 1 or 0 is called a bit (short for "binary digit"), and bits are grouped into bytes of 8 bits at a time.
Binary is not just a convenient choice — it is a reliable one. Two voltage levels (high and low) are easy for hardware to tell apart even with electrical noise on the line. A system with ten voltage levels, one for each denary digit, would be far more likely to misread a value. Binary arithmetic circuits are also simpler to design than decimal ones, which is one reason every modern processor is built around base 2 rather than base 10.
Place value in binary
Denary (base 10) uses place values of 1, 10, 100, 1000 and so on — each column is 10 times the value of the one to its right. Binary (base 2) works the same way, except each column is only 2 times the value of the one to its right, because there are only two digits available (0 and 1) instead of ten.
A 1 in a column means "include that column's value"; a 0 means "don't include it." To convert binary to denary, you add up the value of every column containing a 1.
| Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
|---|---|---|---|---|---|---|---|
| 2⁷ | 2⁶ | 2⁵ | 2⁴ | 2³ | 2² | 2¹ | 2⁰ |
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
To convert denary to binary, work from the largest column down: if the column's value fits into what is left of your number, write a 1 and subtract it; otherwise write a 0 and move to the next column.
Range of positive integers
With n bits, you can represent 2ⁿ different values. Because counting starts at zero, the range of positive integers representable is 0 to 2ⁿ − 1 — not 0 to 2ⁿ.
| Bits (n) | Total values (2ⁿ) | Range |
|---|---|---|
| 4 bits | 16 | 0 to 15 |
| 8 bits | 256 | 0 to 255 |
| 16 bits | 65,536 | 0 to 65,535 |
| 32 bits | 4,294,967,296 | 0 to 4,294,967,295 |
💡 All 256 possible 8-bit patterns are used for positive values, from 00000000 (zero) up to 11111111 (255). Unlike two's complement — which you'll meet next lesson — there is no negative zone here: every pattern is a positive integer or zero.
This formula matters beyond the classroom: it is exactly why a database field, a variable, or a network address has a hard upper limit. Once every bit pattern is used up, the next number simply cannot be represented — the value overflows.
Worked examples
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1Check: 64 + 16 + 8 + 4 + 1 = 93 ✓
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1- Dropping leading zeros. If a question asks for 8-bit binary, the answer must always have 8 digits. 1011 is not a valid answer for an 8-bit field — it must be written as 00001011.
- Confusing the count of values with the maximum value. n bits give 2ⁿ different values, but the largest value storable is 2ⁿ − 1 (because 0 is one of those values). Stating the range as "0 to 2ⁿ" instead of "0 to 2ⁿ − 1" is a very common one-mark loss.
- Misreading which end is most significant. The leftmost bit is always the most significant (largest place value). Writing the place-value table back to front — treating the rightmost bit as 128 — silently produces the wrong answer.
- Not checking the answer. After converting binary to denary, quickly re-add the columns you picked out. This ten-second habit catches simple addition slips before they cost a mark.
Binary/denary conversions are usually worth 1 mark each and are entirely mechanical — there is no trick, only method. Always draw the place-value table as working, even if you can do the sum in your head; it is the fastest way to check your own answer and to pick up method marks if the final answer is wrong.
Expect these question forms:
- "Convert XXXXXXXX (8-bit binary) to denary" (1 mark)
- "Convert X to 8-bit binary" (1 mark)
- "State the range of values representable using n bits" (1 mark) — answer as "0 to 2ⁿ − 1", not just "2ⁿ"
- "State the minimum number of bits needed to represent a given value or range" (1–2 marks)
Task Set A
Task Set B
Higher Computing Science → Computer Systems → CS1
This is a settling-in lesson as well as content. Pupils are new to you and to Higher. Keep it warm. Binary conversion is revision for almost everyone — the goal is building confidence and establishing your classroom rhythm, not hard new material.
Suggested timing (120 min double):
10 min — intro/why binary, settle the class
10 min — warm up independently, then check together
5 min — key vocabulary
15 min — place values + Examples 1 and 2 together on the board
10 min — range of values and the range-map visual
10 min — Example 3 and Now you try (independent, then reveal)
5 min — common mistakes ("has anyone made this one just now?")
25 min — Task Set A
10 min — whole-class check (cold call conversions)
10 min — preview of next lesson: ask "how would you store −5 in binary?" to set up CS2
Watch for: dropped leading zeros; confusing 2ⁿ with 2ⁿ − 1 for the maximum value; place-value table written back to front.
Pupils who find this straightforward should move to Task Set B (extension) immediately rather than waiting.