seegongsik
Structure

How does a computer use 0 and 1

Photos, music, video: inside a computer, all of it comes down to just two states. You can see what those two states are with nothing more than a switch on your desk. Let's flip switches one at a time and work it out.

01

On or off, nothing in between

A light switch is either on or off. There's no fuzzy half-on setting. Computer parts work the same way: current either flows through a circuit or it doesn't.

So we agreed to call on 1 and off 0. That's all 0 and 1 really are. They aren't a secret code, just names for the two states of a switch. Flip a light switch up and the light comes on, flip it down and it goes off, and the same thing happens inside a computer. The difference is that its switches are far too small to see, and a single chip holds billions of them.

0
Now: Off = 0

Each tap switches between on and off. When the page first opens, it blinks once by itself.

02

Wouldn't counting in tens be easier?

We have ten fingers, so we're used to the digits 0 through 9. So why not let a computer split electricity into ten levels too? The trouble is that telling ten levels of current apart reliably is very hard.

In the picture below, the top row is a lamp with ten brightness levels. Neighboring levels look so alike that it's hard to tell which one you're seeing. The bottom row has only on and off, so there's nothing to mix up. That certainty is exactly why computers chose two levels.

You can tell 9 from 8 at a glance, but to a machine, 9 units of current and 8 units of current are very close. A small wobble in voltage is enough to read a 9 as an 8. On and off are so far apart that ordinary wobbles don't matter. For a computer that has to be fast and accurate, that certainty mattered more than anything.

Ten levels
↓
Two levels

Ten levels blur into their neighbors; two levels are clear at a glance.

03

Line switches up and you get a number

One switch can only show two things, 0 or 1. Put several side by side and give each position a value, though, and everything changes. The rightmost position is worth 1, and each step to the left doubles it: 2, 4, 8, and so on.

1
×2
2
×2
4
×2
8
×2
16
×2
32
×2
64
×2
128

Place values double as you move from right to left.

Now it's your turn. Tap any of the 8 switches below, and the sum of the place values that are on appears at the top. That sum is the number the computer reads. Your first mission is to make 13.

128
0
64
0
32
0
16
0
8
0
4
0
2
0
1
0
0 0 0 0 0 0 0 0
Add up the values that are on
 
0
Mission: make 13

Add up the values that are on and the number at the top changes. 13 = 8 + 4 + 1.

04

Counting up from 0

In decimal, after 9 you carry to the next place and get 10. Binary carries too when a place fills up. The only difference is that it carries right after 1. Press play and watch the bits blink as the count goes up one at a time.

0
0
0
0
0
0
0
0
0

The rightmost bit flips on every step; the one next to it flips every second step.

Once the pattern clicks, it feels natural that 0s and 1s can count as high as you like. Our decimal system works on exactly the same idea. The only difference is whether each place holds ten digits, 0 through 9, or just two, 0 and 1.

05

What about letters and pictures?

Let's go one step further. If a computer only handles numbers, how does it show letters? The answer is surprisingly simple. Every letter gets a number from an agreed table: A is 65, B is 66, and so on.

Pick a letter below. Its number turns straight into 0s and 1s, and small cells switch on and off to show it. Pictures work the same way. Write the color of each dot as a number, and in the end everything becomes 0s and 1s.

The screen you look at every day is built this way. Each of its countless dots stores its color as a number, and that number is stored again as 0s and 1s. Text, photos, video: open any of them up and you find the same string of 0s and 1s. They aren't made of different stuff; they're different things shaped from the same material.

A
Number 65 written as 0s and 1s
0 1 0 0 0 0 0 1

Pick a letter and its number turns into 0s and 1s.

06

Each extra switch doubles it

Here's the most surprising part. Every switch you add doubles the number of patterns you can show. 1 switch gives 2, 2 give 4. That may not sound like much, but push the slider below all the way and see.

Loading 3D…
2 options
1 bits · 2¹

Add bits and the number of lit cubes doubles each time. You can also drag to rotate it.

With only 8 bits there are already 256 patterns. With 16 there are more than 60,000. Doubling again and again gets enormous fast. That's how such simple switches manage to hold so much of the world. Units like giga and tera are just ways of counting how many of these switches have been gathered together.

In one lineA single photo or your favorite song is, deep down, switches turning on and off. The 0s and 1s that looked complicated were just a way of counting switch states.
← Structure
Was this helpful? Support seegongsik