Binary Numbers — How Computers Count

Why computers use 0s and 1s, and how they represent any number

Computer Science Fundamentals beginner 5 min
Step 1 of 5

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

Step 1 of 5
  1. 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. 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. 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. 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. 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.

Added
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.