Mathematics / Binary numbers

Binary numbers

How to write any whole number with only 0 and 1: place values that double, counting with carries, converting both ways, and why this suits a machine made of switches.

Beginner7 steps~6 min
Bit set to 1 — this column counts
Bit set to 0 — this column is skipped
Place value — what a 1 in that column is worth
// THE SHORT VERSION

In 30 seconds

Binary is a way of writing numbers with two digits instead of ten. Each column is worth twice the one on its right: 1, 2, 4, 8, 16 and so on.

To read a binary number, add the place values of the columns that hold a 1. So 1101 is 8 + 4 + 1 = 13.

Computers use it because their parts are switches with two reliable states, on and off. One binary digit is a bit; eight bits make a byte, which can hold 256 different values.

Binary numbers, step by step

STEPS01 / 07

This lesson covers whole numbers from zero up. Negative numbers and fractions use extra conventions (two’s complement, floating point) built on the same bits.

STEP 01 / 07 Place values in base ten
THE MATH
205 = 2×100 + 0×10 + 5×1
  1. Step 1: Place values in base ten. Everyday numbers use ten digits. A digit’s position decides what it is worth: ones, tens, hundreds, each column ten times the one before. Binary keeps this system and changes only the ten.
  2. Step 2: Base two: columns double. Binary has only two digits, 0 and 1, so each column is worth twice the one on its right: 1, 2, 4, 8. A 1 means the column counts, a 0 means it is skipped. One binary digit is called a bit.
  3. Step 3: Counting in binary. Counting works as in decimal, but a column fills up after 1 instead of after 9. Adding one to a 1 resets it to 0 and carries into the next column, so 1 is followed by 10, 11 by 100, and 111 by 1000.
  4. Step 4: Binary to decimal. To read a binary number, write the place values above the bits, doubling from the right, and add up the columns that hold a 1. Here that is 32, 8, 4 and 1, which make 45.
  5. Step 5: Decimal to binary. To go the other way, divide by 2 over and over and note each remainder. The first remainder says whether the number is odd, so it is the ones bit; the last one is the leftmost bit. Read from the bottom up, 45 gives 101101.
  6. Step 6: Why computers use two. A computer is built from transistors acting as switches, and a switch has two clear states. A wire only has to be told apart as high or low, so a signal blurred by noise is still read correctly. Ten levels in the same range would sit too close together.
  7. Step 7: Bits and bytes. Bits are handled in groups of eight called bytes. Our 45 fits in one byte as 00101101; the zeros on the left add nothing. Eight bits make 256 different patterns, enough for the numbers 0 to 255, and every extra bit doubles the count.
VALUES SO FAR
base 10columns ×10rule
base 2····rule
1101····example
1 + 1····rule
101101····result
45····result
states····hardware
1 byte····unit
range····byte
// BEFORE

Learn this first

Nothing. This concept starts from scratch.

Spotted a mistake on this page?