A transistor is a switch. It is either conducting or it is not — on or off, high voltage or low. There is no reliable "a bit on", because component tolerances, temperature and electrical noise would make a ten-level signal unreadable. So computers count in a system with exactly two digits: binary. Everything else follows from that one hardware fact.
Place value is the whole trick
You already understand binary, because you already understand place value. In decimal, 305 means 3 hundreds, 0 tens, 5 ones — each column is worth ten times the one to its right, because there are ten digits. In binary there are two digits, so each column is worth twice the one to its right: 1, 2, 4, 8, 16, 32, 64, 128. Nothing else changes.
Binary to decimal
Write the place values above the bits, then add up only the places with a 1 underneath. That is the entire method, and it works for any width.
Decimal to binary
Two methods work, and you should know both. The subtraction method is faster once you know the powers of two by heart: take the largest power of 2 that fits, write a 1, subtract it, repeat. The division method is more mechanical and harder to get wrong: divide by 2 over and over, writing down each remainder, then read the remainders bottom to top.
| Divide by 2 | Quotient | Remainder |
|---|---|---|
| 181 ÷ 2 | 90 | 1 |
| 90 ÷ 2 | 45 | 0 |
| 45 ÷ 2 | 22 | 1 |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Why hexadecimal exists
Binary is correct but unreadable — nobody can dictate 11010110 over the phone without a mistake. Hexadecimal (base 16) fixes this because 16 is 2⁴, so exactly four bits make exactly one hex digit, with no arithmetic across the boundary. A byte becomes two characters. A colour becomes six. A memory address becomes eight. That is why every error code, MAC address and colour code you will ever see is written in hex.
| Decimal | Binary (4-bit) | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
Notation
- Binary: a subscript 2 (), a
0bprefix (0b1011), or the word stated — never assume. - Hexadecimal: a subscript 16, a
0xprefix (0xB5), or a#in colour codes (#FF8800). - Decimal: usually nothing, or a subscript 10 when the context is ambiguous.
101with no marking is genuinely ambiguous — it is 101 in decimal, 5 in binary, and 257 in hex.