Counting in Binary and Powers of Two
Count from 0 to 15 in binary, learn the place values 1, 2, 4, 8 and up, and see how many values a given number of bits can represent.
Welcome back!
Step 1 of 12Learn
Counting with only 0 and 1
Counting in binary follows exactly the same rule as decimal, just with fewer digits. In decimal you count 0, 1, 2 up to 9, run out of digits and carry. In binary you run out after 1.
So: 0, 1, and then the ones place is full. Write 0 and carry 1 to the next place: 10. That's binary for two. Then 11 (three). Now both places are full, so carry again: 100 (four).
| Decimal | Binary | Decimal | Binary |
|---|---|---|---|
| 0 | 0 | 8 | 1000 |
| 1 | 1 | 9 | 1001 |
| 2 | 10 | 10 | 1010 |
| 3 | 11 | 11 | 1011 |
| 4 | 100 | 12 | 1100 |
| 5 | 101 | 13 | 1101 |
| 6 | 110 | 14 | 1110 |
| 7 | 111 | 15 | 1111 |
Look down the binary column and you'll spot patterns. The rightmost bit alternates 0, 1, 0, 1. The next bit alternates every two numbers, the next every four, the next every eight. And every time the number is all 1s (1, 11, 111, 1111), the next number is a 1 followed by all 0s, exactly like 999 rolling over to 1000.
A joke programmers love: "There are 10 kinds of people in the world: those who understand binary and those who don't." Now you're in the first group.
Step 2 of 12Practice · Put in order
Put these binary numbers in counting order, from smallest to largest.
Drag the items, or use the arrow buttons, to put them in order.
- 111
- 110
- 1001
- 101
- 1000
Step 3 of 12Diagram
Counting from 0 to 7 in binary
Tap a shape with to see more.
- 0
- 1
Out of digits already.
- 10
Carry: two is written 10.
- 11
- 100
Both places are full, so carry twice.
- 101
- 110
- 111
Seven: every place is 1.
Step 4 of 12Learn
The binary place values
In decimal, places are worth powers of 10. In binary, they're worth powers of 2. From right to left:
| 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
|---|---|---|---|---|---|---|---|
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Each place is worth double the place to its right. Memorize these eight; you'll use them constantly. It also helps to know a few bigger ones: 210 = 1,024, which is close to a thousand and is why computer memory sizes often come in multiples of 1,024, and 216 = 65,536.
The rightmost bit, worth 1, is called the least significant bit (LSB). The leftmost is the most significant bit (MSB), because it carries the biggest value.
A neat property: since only the ones place is odd, a binary number is odd if its last bit is 1 and even if it's 0. You can tell 1011 is odd and 1010 is even without converting either.
Groups of bits have names. One bit is a bit. Four bits make a nibble. Eight bits make a byte, the basic unit for measuring memory and file sizes.
Step 5 of 12Practice · Chart
Binary place values double each step
Tap the place worth 32.
Tap the bar that answers the question, then press Check.
Step 6 of 12Practice · Fill in the blanks
Fill in the blanks
Reading from right to left, the first five binary place values are 1, 2, 4, and . A group of 8 bits is called a .
Step 7 of 12Learn
How many values fit in n bits?
Here's one of the most useful facts in computing: n bits can represent 2n different values.
Why? Each bit has 2 options. With 1 bit there are 2 patterns. Add a second bit and each of those patterns can be followed by a 0 or a 1, doubling the count to 4. A third bit doubles again to 8. Every added bit doubles the possibilities.
| Bits | Patterns | Range (starting at 0) |
|---|---|---|
| 1 | 2 | 0 to 1 |
| 4 | 16 | 0 to 15 |
| 8 | 256 | 0 to 255 |
| 16 | 65,536 | 0 to 65,535 |
| 32 | about 4.3 billion | 0 to 4,294,967,295 |
Notice the largest value is always 2n − 1, one less than the number of patterns, because one pattern is used for zero. A byte holds 256 values, but the biggest is 255.
You'll see these numbers everywhere once you know them. Why do some old games cap a stat at 255? It's stored in one byte. Why did older internet addresses run short at about 4.3 billion? They're 32-bit numbers. Why do color values go from 0 to 255? One byte per color channel.
Going the other way, to store N different values you need the smallest n with 2n ≥ N.
Step 8 of 12Explore
Doubling with every bit
The curve shows how many values n bits can represent. Drag the slider to choose a number of bits and read the exact counts.
- Different values (2n)
- 256
- Largest value (2n - 1)
- 255
Step 9 of 12Practice · Work it out
A game stores each player's level in 6 bits, starting at level 0. What is the highest level it can store?
Step 10 of 12Note
Step 11 of 12Practice · Diagram
One hand, five bits
Which single finger raised on its own shows the number 8?
Tap the shape that answers the question, then press Check.
- Right hand: 0 to 31
- Thumb = 1
- Index = 2
- Middle = 4
- Ring = 8
- Pinky = 16
Step 12 of 12Practice · Work it out
A school needs a unique code for each of its 300 lockers. What is the fewest number of bits that can give every locker a different code?
Lesson complete!