TactivergeLite

Lite / Discovering How the World Works / Week 15

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 · Reviewed by the founders' mentors · Full interactive version

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.

Predict

In binary, what comes after 1?

  1. 2
  2. 10
  3. 11
Guess first, then reveal

10. Binary has only the digits 0 and 1, so after 1 you run out of digits, write a 0 and carry 1 into the next place, just like 9 → 10 in ordinary counting. Binary 10 means two.

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.

What the interactive shows (text version)

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.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: 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.

“Representing Numbers and Letters with Binary: Crash Course Computer Science #4” by CrashCourse (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

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

Intuitive

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.

Technical

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.

Mathematical

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.

Applied

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

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 2. What comes next after 0111 in 4-bit binary?

Practice 4. When counting up in binary, which bit changes every time?

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.

Reflect

What feels the same and what feels different about counting in binary compared with decimal?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Pictures as numbers: pixelsConverting: binary to decimal and back →