Binary arithmetic: writing numbers with 0 and 1
Why do we count in tens? Probably because we have ten fingers. There is nothing special about the number 10: any number can be written in any base. Leibniz took this idea to the extreme and asked: what is the smallest number of digits that can write everything?
The answer is two: 0 and 1.
Each place is worth double
In the decimal system the places are worth 1, 10, 100, 1000… and each digit says how many times we use that value. In the binary system the places are worth 1, 2, 4, 8, 16, 32… and each digit can only say yes (1) or no (0).
$$10110_2=1\cdot16+0\cdot8+1\cdot4+1\cdot2+0\cdot1=22.$$The subscript $_2$ reminds us that the number is written in base 2. With eight places, or eight bits, the values go from 1 to 128, and the largest number we can write is
$$11111111_2=128+64+32+16+8+4+2+1=255.$$Counting zero, that makes $2^8=256$ different numbers. That is why so many things in computing run from 0 to 255.
Converting and adding
To write 13 in binary, we divide by 2 repeatedly and note the remainders:
| Division | Quotient | Remainder |
|---|---|---|
| 13 ÷ 2 | 6 | 1 |
| 6 ÷ 2 | 3 | 0 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from bottom to top: $13=1101_2$. Check: $8+4+0+1=13$.
Addition is even simpler than in decimal, because there are only four cases: $0+0=0$, $0+1=1$, $1+0=1$ and $1+1=10_2$, which is “zero, carry one”. For example,
$$101_2+11_2=1000_2,\qquad\text{that is,}\qquad5+3=8.$$The whole multiplication table fits on one line: $0\times0=0$, $0\times1=0$, $1\times1=1$. Leibniz was delighted: multiplying becomes nothing but copying and shifting.
Egyptian multiplication
The idea of doubling is much older than Leibniz. In the Rhind papyrus, copied by the scribe Ahmes around 1550 BC, the Egyptians multiplied by doubling and adding alone. To compute $21\times37$, one makes a table that starts with $1$ and $37$ and doubles both columns on each row:
| Doubles of 1 | Doubles of 37 |
|---|---|
| 1 | 37 |
| 2 | 74 |
| 4 | 148 |
| 8 | 296 |
| 16 | 592 |
In the left column, pick the rows that add up to 21: $16+4+1=21$. Adding the matching rows on the right, $592+148+37=777$. So $21\times37=777$.
Why does it work? Picking the rows is writing 21 in binary: $21=10101_2=16+4+1$. Then
$$21\times37=(16+4+1)\times37=592+148+37.$$Every positive integer can be written in exactly one way as a sum of distinct powers of 2, so the method never fails. The Egyptians were calculating in binary three thousand years before Leibniz, without knowing it. A variant, which halves one factor and doubles the other, became known in Europe as Russian peasant multiplication, and it is close to what processors still do today.
From nothing and one
Leibniz studied the binary system in manuscripts of 1679 but was slow to publish. For him binary also had a religious meaning: all numbers arise from 1 and 0, just as, in his view, the world was created by God out of nothing.
The Chinese book
Leibniz corresponded with Joachim Bouvet, a Jesuit missionary living in China. In 1701 Bouvet sent him the 64 hexagrams of the I Ching, a Chinese book of divination about three thousand years old. Each hexagram has six lines, which can be solid or broken.
Leibniz saw it at once: replacing a broken line by 0 and a solid line by 1, and following the traditional order attributed to the sage Fu Xi, the hexagrams were the numbers from 0 to 63 written in binary. He was fascinated and included the discovery in the paper he finally published in 1703 in the journal of the Paris Academy: Explanation of Binary Arithmetic.
From paper to computer
For more than two centuries, binary was a curiosity. That changed in 1937, when the American engineer Claude Shannon showed that electrical circuits with switches, on or off, could do arithmetic in binary. Today every computer, phone and calculator stores numbers and text as long sequences of 0s and 1s.
Leibniz did not invent the computer, nor was he the only one to think of counting with two symbols. But he was the one who organized binary arithmetic, showed how to calculate with it and argued that it revealed something deep about numbers.
Exercise: write 19 in binary
$19=16+2+1$, so $19=10011_2$. With eight bits: $00010011_2$.
Exercise: what is 111111₂? And how does it relate to 2⁶?
$32+16+8+4+2+1=63=2^6-1$. In general, $n$ consecutive 1s are worth $2^n-1$, just as $999=10^3-1$ in decimal.
Sources: Leibniz and binary arithmetic, Mathematical Association of America · MacTutor biography.
All Leibniz topics · ← The ∫ sign: from sum to accumulation · Leibniz’s machine: turning sums into motion →