8 Bits: A Very Common Building Block
In digital systems, bits are rarely used one at a time. Instead, they are grouped into convenient units. The most common grouping is the byte:
1 byte = 8 bits
Because each bit can be 0 or 1, the total number of possible patterns is:
2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 = 28 = 256 patterns
When we use 8 bits to represent unsigned integers (only zero and positive numbers. No negative numbers.), each unique pattern of bits corresponds to a different number. If we start counting at 0, those 256 patterns represent the integers from 0 to 255. This 0–255 range appears all over computing: pixel values, color channels, and simple data types in many programming languages.
Binary Place Value for 8‑Bit Integers
You and your students are already familiar with decimal (base 10) place values: ones, tens, hundreds, and so on. Each place is 10 times the value of the place to its right.
| Position | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| Place value | 1000 | 100 | 10 | 1 |
If we wanted to represent 154, we would know that we need 1 group of 100, five groups of 10, and 4 groups of 1.
154 can be written as 1×100 + 5×10 + 4×1
Binary (base 2) uses the same idea of place value, but the pattern is built from powers of 2 instead of powers of 10. Each place is worth twice the value of the place to its right.
For an 8‑bit binary number, the place values from left to right are:
| Bit position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Power of 2 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
When a bit is 1, we "include" that place value in our total. When it is 0, we do not.
If you can only have 1 or 0 of a particular place value, it takes a bit more information to encode a number in binary than it does in decimal. To represent 154 we would need 1 group of 128, 1 group of 16, 1 group of 8, and 1 group of 2 (since 154 = 128 + 16 + 8 + 2). Encoded in binary, this looks like:
Converting Binary to Decimal
To convert an 8‑bit binary number to decimal, we multiply each bit by its place value and add the results.
Example: What number is 01010110?
Before reading the solution, try working this out yourself using the place value table above.
Consider this 8-bit binary number:
01010110
Match each 1 with its place value:
- 0 × 128 = 0
- 1 × 64 = 64
- 0 × 32 = 0
- 1 × 16 = 16
- 0 × 8 = 0
- 1 × 4 = 4
- 1 × 2 = 2
- 0 × 1 = 0
Add the non‑zero terms:
64 + 16 + 4 + 2 = 86
So 01010110 in binary represents the decimal number 86.
Converting Decimal to 8-Bit Binary
To convert from decimal to binary, one teacher-friendly method is the "place value subtraction" approach. The idea is simple: work through the binary place values from largest to smallest, asking at each step "does this place value fit into what I have left?" If yes, write a 1 and subtract. If no, write a 0 and move on.
Worked Example: Convert 156 to 8-bit binary
We will work through each of the 8 bit positions from left to right, starting with the largest place value (128) and ending with the smallest (1). At each step we ask: does this place value fit into our remaining amount?
| Place value | Remaining | Does it fit? | Bit | New remaining |
|---|---|---|---|---|
| 128 | 156 | Yes (156 ≥ 128) | 1 | 156 − 128 = 28 |
| 64 | 28 | No (28 < 64) | 0 | 28 |
| 32 | 28 | No (28 < 32) | 0 | 28 |
| 16 | 28 | Yes (28 ≥ 16) | 1 | 28 − 16 = 12 |
| 8 | 12 | Yes (12 ≥ 8) | 1 | 12 − 8 = 4 |
| 4 | 4 | Yes (4 ≥ 4) | 1 | 4 − 4 = 0 |
| 2 | 0 | No (0 < 2) | 0 | 0 |
| 1 | 0 | No (0 < 1) | 0 | 0 |
Reading the bits from top to bottom gives us:
10011100
So 156 in decimal is 10011100 in 8-bit binary.
We can verify: 128 + 16 + 8 + 4 = 156. ✓
There are other methods (such as repeated division by 2), but this place-value approach is often easier to connect to students' existing understanding of decimal place value.
Now You Try: Convert 105 to 8-bit binary
Use the same place-value subtraction method. Work through each bit position from 128 down to 1, asking at each step whether the place value fits into your remaining amount. Write down your answer before expanding the solution below.
Show Answer
| Place value | Remaining | Does it fit? | Bit | New remaining |
|---|---|---|---|---|
| 128 | 105 | No (105 < 128) | 0 | 105 |
| 64 | 105 | Yes (105 ≥ 64) | 1 | 105 − 64 = 41 |
| 32 | 41 | Yes (41 ≥ 32) | 1 | 41 − 32 = 9 |
| 16 | 9 | No (9 < 16) | 0 | 9 |
| 8 | 9 | Yes (9 ≥ 8) | 1 | 9 − 8 = 1 |
| 4 | 1 | No (1 < 4) | 0 | 1 |
| 2 | 1 | No (1 < 2) | 0 | 1 |
| 1 | 1 | Yes (1 ≥ 1) | 1 | 1 − 1 = 0 |
Reading the bits from top to bottom gives us:
01101001
So 105 in decimal is 01101001 in 8-bit binary.
We can verify: 64 + 32 + 8 + 1 = 105. ✓
Why the 0–255 Range Matters
Because 8 bits can represent 256 different patterns, a single byte can store integers from 0 to 255 when used as an unsigned value. This simple fact shows up in many real‑world contexts:
- Grayscale images often use 0–255 to represent black to white.
- Each color channel (R, G, and B) in a simple RGB image is usually an 8‑bit value.
- Many introductory programming languages use 8‑bit or 16‑bit integers behind the scenes for simple data.