Skip to content
BetterDL

Binary

Also called: base 2, base-2, binary number, binary number system

The base-2 number system, which writes every value with only the digits 0 and 1. Each position is worth twice the one to its right.

Binary is the number system computers use internally. It has two digits, 0 and 1, and each place is worth double the place to its right: 1, 2, 4, 8, 16, 32, and so on.

Why two digits? A circuit stores each digit as a voltage. If a wire only needs to be low or high, small amounts of electrical noise don't matter: anything near 0 V reads as 0 and anything near the supply voltage reads as 1. Transistors also behave naturally as on/off switches. Two reliable states means base 2.

Each binary digit is called a bit. To read a binary number, add the weights that sit over the 1s: 1011₂ = 8 + 2 + 1 = 11. To go the other way, see decimal to binary conversion.

Long binary strings are hard for people to read, so engineers usually write them in hexadecimal (4 bits per digit) or octal (3 bits per digit). The bits underneath are the same.

Binary isn't only for numbers. The same 0s and 1s are the false/true values of Boolean algebra, which is why digital logic can treat a bit as a number and as a logic signal at the same time.

1
8
0
4
1
2
1
1

Worked examples

Example

Reading and writing 1011₂

Go from binary to decimal by adding weights, then rebuild the bits from the decimal value.

  1. 1.

    Weights from the right: 1, 2, 4, 8.

  2. 2.

    The 1s sit under 8, 2 and 1. The 4s bit is 0, so it adds nothing.

  3. 3.

    8 + 2 + 1 = 11, so 1011₂ = 11₁₀.

  4. 4.

    Going back: 11 = 8 + 2 + 1, so the 8s, 2s and 1s bits are 1 and the 4s bit is 0, giving 1011₂.

Example

Counting from 0 to 8

0, 1, 10, 11, 100, 101, 110, 111, 1000. Every time a run of 1s fills up, it rolls over to 0s and a new 1 appears on the left, just like 99 + 1 = 100 in decimal. See binary counting.

Common mistakes

  • Reading binary as decimal: 101₂ is five, not one hundred and one.

  • Weighting from the left. The rightmost bit is always worth 1.

  • Thinking binary is less exact than decimal. It represents whole numbers exactly; it just needs more digits (about 3.3 bits per decimal digit).

Practice Binary

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Binary is taught in Number Systems.