# Binary code

> Writing everything, numbers, text, images, with only two symbols: 0 and 1.

- Level: Basic
- Topics: Hardware
- URL: https://tidbit.legios.com.ar/binary-code/
- In Spanish: [Código binario](https://tidbit.legios.com.ar/es/binary-code/)

**Binary code** is a way of representing information using only two symbols, 0 and 1. Computers use it because their hardware is built from billions of tiny switches, transistors, that are either on or off. Two states are easy to tell apart reliably, even when electrical signals are a bit noisy, so everything a computer stores or processes ends up as long strings of zeros and ones.

Binary numbers work like the decimal numbers you already know, just with two digits instead of ten. In decimal, each position is worth ten times the one to its right: ones, tens, hundreds. In binary, each position is worth twice as much: 1, 2, 4, 8, 16 and so on. So `1101` means one 8, one 4, no 2 and one 1, which adds up to 13.

Anything else is a matter of agreeing on a code. Text uses tables like ASCII or Unicode, where the capital letter A is the number 65, or `01000001`. An image is a grid of pixels, each with numbers for its red, green and blue. A song is thousands of sound measurements per second. Even the programs themselves are binary: the instructions a CPU runs are patterns of bits that tell it what to do next.

## An analogy

Like Morse code, which spells out every letter with just dots and dashes. Binary does the same with 0 and 1, and a computer can read and write it billions of times per second.

## Keep in mind

- Uses only two symbols, 0 and 1, matching switches that are off or on.
- Each binary position is worth double the one to its right: 1, 2, 4, 8…
- Text, images, sound and programs are all stored as binary.
- Codes like ASCII and Unicode decide which number means which character.

## Go deeper

- [Binary code on Wikipedia](https://en.wikipedia.org/wiki/Binary_code)
- [Binary number on Wikipedia](https://en.wikipedia.org/wiki/Binary_number)

## Related terms

- [Transistor](https://tidbit.legios.com.ar/transistor/): An electrically controlled switch, the basic building block of every chip.
- [Unicode](https://tidbit.legios.com.ar/unicode/): The universal numbering of every letter and symbol, and why accents sometimes break.
- [CPU](https://tidbit.legios.com.ar/cpu/): The chip that runs your programs, one instruction after another, very fast.
