Counting with only 0 and 1
You count 8, 9, 10 because you have ten fingers. How would you count if you only had two?
About 25 min · 3 goals · Checked by automated tests; not yet reviewed by an educator
1.Why should I care?
Every number inside a computer, from your game score to a robot's motor speed, is stored in binary. Reading binary lets you see what a machine is really holding.
- ◇ Explain place value in base 10 and in base 2.
- ◇ Count from 0 to 15 in binary.
- ◇ Read a binary number by adding the place values of its 1s.
2.Predict
In binary, what comes after 1?
Guess first. Being wrong here is how the surprise works.
3.Discover
Use 4 bits. Make the numbers 1 to 15 by flipping switches. Which switch flips every single time you add 1? Which flips least often? Then try the challenges.
Binary switches
Each switch is one bit. Its place value doubles from right to left: 1, 2, 4, 8… Add up the places that are ON to read the number.
Register size
Challenge: make 5
= 0
4 bits make 16 different patterns, from 0 up to 15.
0000 in binary = 0 = 0.
Can't use the interactive? Read a description instead
The binary switches diagram labels each switch with its place value: 8, 4, 2, 1 for 4 bits (or 128 down to 1 for 8). Turning switches on adds their place values; the total is shown and read out, for example '1011 in binary = 8 + 2 + 1 = 11'. Pressing 'Add 1' counts up; the rightmost switch flips every time.
4.Watch
→ Watch for how binary place values (1, 2, 4, 8…) work just like decimal ones (1, 10, 100…).
Shows how ones and zeros can stand for numbers and text, so binary stops feeling like magic.
10 min 45 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
5.Understand
Place value, the familiar way
In ordinary decimal numbers each place is worth ten times the one to its right: ones, tens, hundreds. 352 means 3 × 100 + 5 × 10 + 2 × 1. You carry when a place goes past 9.
Place value in base 2
In binary, each place is worth two times the one to its right: 1, 2, 4, 8, 16, 32, 64, 128. Each place holds only 0 or 1. To read 1011, put the place values over the bits: 8, 4, 2, 1. Add the places with a 1: 8 + 2 + 1 = 11.
Counting up
0, 1, 10, 11, 100, 101, 110, 111, 1000… The rightmost bit flips every time. The next flips every 2 counts, the next every 4, the next every 8. It's the same carrying you already know, just carrying at 2 instead of 10.
Explain it another way
Imagine coins worth 1, 2, 4 and 8 pence, and you have exactly one of each. Any amount from 0 to 15 can be paid by choosing which coins to hand over. Binary is just a list of which coins you used.
A base-b positional number dₙ…d₁d₀ has value Σ dᵢ × bⁱ. In base 2 each digit dᵢ ∈ {0, 1}, so the value is the sum of the powers of two whose bits are set.
1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13. 100000₂ = 32. The largest n-bit number is 2ⁿ − 1: for 4 bits, 1111₂ = 8 + 4 + 2 + 1 = 15.
Programmers working close to the hardware read registers in binary: each bit might mean 'motor on', 'LED on' or 'button pressed', and the whole register is also just a number.
Worked example 1
Read the binary number 10110.
Place values for 5 bits: 16, 8, 4, 2, 1. Bits: 1 0 1 1 0. Add 16 + 4 + 2 = 22.
Common mix-ups
- Binary 10 means ten.
✓ Binary 10 means one two and no ones: two. Always check which base a number is written in.
6.Practice
Practice, not a test. Wrong answers get a hint and another try.
Practice 1 · a fresh version every time
What number is the binary pattern 1010 in ordinary (decimal) counting?
Practice 2
What comes next after 0111 in 4-bit binary?
Practice 3
In binary, what is the place value of the 5th bit from the right?
Practice 4
When counting up in binary, which bit changes every time?
7.Apply it
Count in binary on one hand: each finger is a bit (thumb = 1, index = 2, middle = 4, ring = 8, little = 16). What is the biggest number you can show? Show your age in binary.
8.Reflect
Concepts: Binary, hexadecimal and digital signals