Electronics School · Stage 4: Explore Digital Electronics · Lesson 19

Binary Numbers

How computers count using only two digits: on and off.

The question

How can a computer store a photo, a song or this whole page using nothing but switches that are either on or off?

What you’ll discover: how binary numbers work, why digital electronics uses them, and how to convert between binary and ordinary numbers.

In simple terms

BeginnerCounting with two digits

We normally count in decimal, with ten digits (0 to 9), probably because we have ten fingers. Computers count in binary, which has only two digits: 0 and 1. That suits electronics perfectly, because a transistor switch is either off (0) or on (1).

Each binary digit is called a bit. In decimal, each place is worth ten times the one to its right (ones, tens, hundreds). In binary, each place is worth two times the one to its right: 1, 2, 4, 8, 16, 32, 64, 128.

Example: binary 1011 = 8 + 0 + 2 + 1 = 11 in decimal.

Try it: the binary switchboard

Each switch is one bit. Flip them on and off and watch the number change.

Challenge: make 5, then 10, then 255. What’s the biggest number eight bits can hold?

Go deeper

IntermediateBytes and what they hold

Eight bits make a byte, which can hold any number from 0 (00000000) to 255 (11111111): 256 different values.

Everything digital is stored as patterns of bits. Text uses codes where each character has a number: in the common ASCII and UTF-8 codes, the capital letter A is 65 (binary 01000001). A photo is millions of tiny dots, each stored as numbers for its red, green and blue brightness. A song is tens of thousands of measurements of the sound wave every second.

A gigabyte is about a billion bytes.

AdvancedHexadecimal and why two levels

Long binary numbers are hard to read, so programmers often use hexadecimal (base 16), with digits 0 to 9 and A to F. Each hex digit stands for exactly four bits: binary 1111 1111 is hex FF, which is 255. You’ll see hex in web colours: #FF0000 is full red.

Why only two levels? A circuit only has to tell “high” from “low,” with a wide gap between them, so electrical noise and small voltage changes don’t cause errors. On a 3.3 V microcontroller like the Raspberry Pi Pico, anything above about 2 V reads as 1 and anything below about 0.8 V reads as 0. In between is a no-man’s-land the chip can’t be sure about.

Quick check

What is binary 101 in decimal?

4 + 0 + 1 = 5.

What is the largest number one byte (8 bits) can hold?

255.

Why does digital electronics use binary?

A switch is naturally either off or on, and two widely separated levels are easy to tell apart reliably, even with electrical noise.

Words to know

Bit
A single binary digit: 0 or 1.
Byte
Eight bits.
Binary
Counting in base 2, with only the digits 0 and 1.
Hexadecimal
Counting in base 16, a compact way to write binary.

Learn more

Electronics School is part of the Discovery Zone. Every activity here runs on small batteries or a USB cable: never wall outlets. The one plug-in tool is the optional soldering iron, set up by an adult.

Was this page helpful?
Get all four of our sites in one free email every Friday: Prairie Signals
⇧Top
Hello! “Know what it is you can do better than anyone else, and do that.”