Binary Numbers — How Computers Count
Why computers use 0s and 1s, and how they represent any number
Decimal: Base 10
We normally count in base 10: each digit position is a power of 10. The number 347 = 3×100 + 4×10 + 7×1.
Binary: Base 2
Computers use base 2: each digit (bit) can only be 0 or 1. Each position is a power of 2: 1, 2, 4, 8, 16...
Reading a Binary Number
To read 1011: go right to left. 1×1 + 1×2 + 0×4 + 1×8 = 1 + 2 + 0 + 8 = 11. Each 1-bit adds its column value.
Counting in Binary
Counting 0→7: 000, 001, 010, 011, 100, 101, 110, 111. Each increment flips the rightmost 0 bit — just like a car odometer.
Try It Yourself
Pause the animation, then click the bit buttons below to build any number by hand. Set a target value and see how few bits you can flip to reach it.
How It Works — Step by Step
-
1
Decimal: Base 10
We normally count in base 10: each digit position is a power of 10. The number 347 = 3×100 + 4×10 + 7×1.
-
2
Binary: Base 2
Computers use base 2: each digit (bit) can only be 0 or 1. Each position is a power of 2: 1, 2, 4, 8, 16...
-
3
Reading a Binary Number
To read 1011: go right to left. 1×1 + 1×2 + 0×4 + 1×8 = 1 + 2 + 0 + 8 = 11. Each 1-bit adds its column value.
-
4
Counting in Binary
Counting 0→7: 000, 001, 010, 011, 100, 101, 110, 111. Each increment flips the rightmost 0 bit — just like a car odometer.
-
5
Try It Yourself
Pause the animation, then click the bit buttons below to build any number by hand. Set a target value and see how few bits you can flip to reach it.
Key Takeaways
Why Binary?
Transistors have two states: on or off. Binary maps perfectly to electronics. It is simpler to build reliable hardware with two states than ten.
Powers of 2
Each bit position doubles the previous: 1, 2, 4, 8, 16, 32… An 8-bit byte can represent 0–255 (2⁸ = 256 values).
Carry = Overflow
When all bits are 1 and you add 1 more, all bits flip to 0 and a new bit appears to the left. This is binary carry — the origin of integer overflow.
Connected Concepts
Boolean Logic
AND, OR, NOT — the logic gates that manipulate bits.
Transistors
A transistor pinned fully off or fully on is the physical switch behind every 0 and 1 you just flipped.
Data Storage
Those same bits, grouped and addressed, are how a hard drive or SSD actually stores a file.
Information Entropy
How many bits a message truly needs is a question of entropy, not just its binary length.
Error-Correcting Codes
In a Hamming code, the parity checks that fail spell out, in binary, the position of the flipped bit.
Updated
- — New connection to Error-Correcting Codes.
- — Added a predict question on what the leftmost of five bits is worth, and a goal: build 21 by hand.