Skip to content

Math Inside Computers

Teens & adults Computing Binary

Every computer on Earth — phone, game console, spacecraft — does all of its math in binary: place value with two digits instead of ten. Once you know place value from our bases page, you already understand the whole trick. This page is where arithmetic meets the machine.

Binary: place value with two digits

decimal binary powers of 2 1 0001 1 2 0010 2 4 0100 4 8 1000 8 13 1101 8 + 4 + 1 = 13

A single binary digit is a bit. Eight bits make a byte — one byte counts 0 to 255, which is why 255 keeps appearing in tech (colors, old game stats, network addresses).

Why computers chose binary

Not because binary is elegant — because electronics are reliable at two states (current flowing / not flowing). Claude Shannon proved in 1937–48 that binary arithmetic and true/false logic are the same mathematics, so circuits can "reason":

The famous surprise: 0.1 + 0.2 ≠ 0.3

Type 0.1 + 0.2 into almost any programming language and you'll get 0.30000000000000004. Not a bug — math. Decimal 0.1 is a repeating fraction in binary (like 1/3 is 0.333… in decimal), so the computer stores the nearest value it can, and the rounding shows. Every computer handles this identically because they all follow one standard:

Why this page exists on a programming site Binary, logic, and arithmetic are literally the same subject viewed from different angles — the observation that built the digital age. Jeannette Wing called this blend "computational thinking" and argued it belongs beside reading, writing, and arithmetic: When you're ready, our IDE and learning path put this math to work in real ALB programs.
Try it yourself:
  1. Convert 1010 binary to decimal  (8 + 2 = 10)
  2. How many values fit in 4 bits?  (2⁴ = 16)
  3. Is 0.5 exact in binary?  (yes — it's 2⁻¹)