Why hardware counts in twos
A transistor is a switch: it is either off or on. That is all a chip has to work with, so hardware counts using just two digits, 0 and 1. Each digit is a bit, short for binary digit.
We are used to ten digits, 0 through 9. Binary keeps everything about counting the same and changes only one thing: how many digits a column can hold before it rolls over. Seen next to decimal, binary stops feeling strange.
Place value, the idea
Every number you write already uses place value. In decimal, each column is worth ten times the column to its right.
Figure: A side-by-side comparison
| Column | Hundreds | Tens | Ones |
|---|
| Worth | 100 | 10 | 1 |
| In 352 | 3 | 5 | 2 |
So 352 means (3 x 100) + (5 x 10) + (2 x 1). Binary works in exactly this way, with one change: each column is worth twice the one to its right, not ten times.
Binary columns
In binary, columns double as you move left: 1, 2, 4, 8, 16 and so on.
Figure: Four labelled boxes in a row for a 4-bit number, with place values 8, 4, 2 and 1 written above each box
| Column | Eights | Fours | Twos | Ones |
|---|
| Worth | 8 | 4 | 2 | 1 |
- The rightmost bit is the LSB (least significant bit), worth 1.
- The leftmost bit is the MSB (most significant bit), worth the most.
Each bit answers one yes or no question: is this column's value included or not?
Counting up in binary
Counting works just like decimal, but a column can only hold 0 or 1. When a column would go past 1, it resets to 0 and carries into the column on its left.
| Decimal | Binary |
|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
Read any column top to bottom: the ones bit flips every step, the twos bit every two steps, the fours bit every four. That doubling pattern is binary counting.