Energy and Everyday Technology

How Computers Store Information as Binary

Understand bits, bytes and number systems, and how text, images and sound can all be represented as long strings of ones and zeros inside a computer.

On this page
  1. Two states are enough
  2. Counting with two symbols
  3. Bytes
  4. Text as numbers
  5. Images and color
  6. Sound and other data
  7. Where the bits physically live
  8. Why binary matters

Two states are enough

At the lowest level, a computer is built from enormous numbers of tiny electronic switches. A switch has two easy-to-tell conditions: on or off, or in practice a higher voltage versus a lower one. It is much easier to build parts that reliably tell two conditions apart than parts that tell ten apart, especially when signals are small and fast. So computers represent information with just two symbols, usually written as 0 and 1.

One of these symbols is called a bit, short for binary digit. A single bit can hold only two possibilities, which is not much on its own. The power comes from combining many of them.

Counting with two symbols

In everyday decimal numbers, each position is worth ten times the one to its right: ones, tens, hundreds. Binary works the same way, but each position is worth twice the one to its right: ones, twos, fours, eights, sixteens and so on.

So the binary number 101 means one four, no twos and one one, which is 4 + 0 + 1 = 5. The number 1101 is 8 + 4 + 0 + 1 = 13.

Each extra bit doubles the number of values that can be represented. Two bits give four patterns (00, 01, 10, 11), three bits give eight, and so on. Ten bits give 1,024 patterns, since 2 multiplied by itself ten times is 1,024.

Bytes

Bits are usually handled in groups of eight called bytes. A byte has 256 possible patterns, because 2 to the power of 8 is 256, which is enough to represent the whole numbers from 0 to 255. Larger units are built from bytes: a kilobyte, megabyte and gigabyte are roughly a thousand, a million and a billion bytes.

There is a small wrinkle here. Some people and systems use 1,000 for each step, and others use 1,024, because 1,024 is a natural size in binary. This is why the same drive can appear to have slightly different sizes in different programs.

Text as numbers

A computer has no built-in idea of a letter. To store text, people agree on a table that assigns a number to each character. In a long-standing standard called ASCII, the capital letter A is 65 and B is 66. In binary, 65 is 01000001, which is 64 + 1. So the word “Hi” can be stored as two numbers, one for each character, each written in a byte.

ASCII covers basic English letters, digits and punctuation. A newer standard, Unicode, assigns numbers to characters from a very large range of writing systems, plus symbols and emoji. Some forms of Unicode use more than one byte for a character.

Images and color

A digital picture is a grid of tiny dots called pixels, and each pixel is stored as numbers. A common scheme uses one byte each for the red, green and blue amounts in a pixel. Each amount can be 0 to 255, so the number of possible colors is 256 × 256 × 256, or 16,777,216. A photo is then simply a very long list of such numbers, often compressed to save space.

Sound and other data

Sound is a continuous wave, so to store it a computer measures the height of the wave many thousands of times each second and records each measurement as a number. Playing it back reverses the process, turning numbers into a changing voltage that drives a speaker. Video combines a rapid series of images with sound. Programs are also stored as numbers: the instructions that tell a processor what to do are patterns of bits that the hardware recognizes.

The meaning of a pattern depends entirely on context. The same eight bits could be read as a small number, a letter or part of a color, depending on what the program expects. There is nothing inside the bits themselves that says which.

Where the bits physically live

How a bit is kept depends on the storage type. In memory chips, bits are held as tiny electrical charges or circuit states. In flash storage, charge is trapped in cells. In some hard drives, they are tiny magnetized regions on a spinning disk. In optical discs, they are marks read by a laser. Different physical methods, same idea: two distinguishable states.

Why binary matters

Representing everything as numbers means a single machine can handle text, music, photos and software using the same basic hardware. It also makes copying reliable: as long as each bit is read correctly as a 0 or 1, a copy is identical to the original, which is part of why the internet works well for sending files. Computers also add checking information to data to catch errors that occur in storage or transmission.

Binary is not a deeper truth about information. It is a practical engineering choice that fits the physics of electronic switches very well.

The complete guide to energy and everyday technology

How Energy Powers Modern Life
Read the guide

Keep exploring

Guides from other topics

All topics →