1.1.1How Computers Work

Binary number system — conversions from - to decimal, counting in binary

1,982 words9 min readdifficulty · medium6 backlinks

WHY binary at all?


WHAT is place-value (the engine behind every base)

Derivation from scratch (decimal first, so the idea is familiar): Why does "253" equal two-hundred-fifty-three? Because we agreed each slot is worth ten times the slot to its right: 253=2102+5101+3100=200+50+3253 = 2\cdot 10^2 + 5\cdot 10^1 + 3\cdot 10^0 = 200+50+3 Why this step? The leftmost digit is "further from the units" by two positions, so it's scaled by 10210^2.

Now swap base 10 → base 2. The only thing that changes is the weights become powers of 2, and allowed digits shrink to {0,1}\{0,1\}:


HOW to convert Binary → Decimal


HOW to convert Decimal → Binary (repeated division)


Counting in binary

Figure — Binary number system — conversions from - to decimal, counting in binary

Forecast-then-Verify

Recall Forecast: how many bits to write

10010100_{10}? Then verify. Forecast: 26=642^6=64, 27=1282^7=128. Since 64100<12864 \le 100 < 128, we need 7 bits. Verify (repeated division): 10050100\to50 r0, 502550\to25 r0, 251225\to12 r1, 12612\to6 r0, 636\to3 r0, 313\to1 r1, 101\to0 r1 → bottom-up 11001001100100. That's 7 digits ✓ and 64+32+4=10064+32+4=100 ✓.


Common mistakes


Flashcards

What base does the binary system use, and why is it natural for computers?
Base 2; computer switches have exactly two stable states (off=0, on=1), which are cheap and noise-resistant.
Binary→decimal: what is the weight of the bit at position ii (rightmost = 0)?
2i2^i.
Convert 101121011_2 to decimal.
8+0+2+1=118+0+2+1 = 11.
Convert 1101002110100_2 to decimal.
32+16+4=5232+16+4 = 52.
What algorithm converts decimal to binary?
Repeated division by 2; record remainders; read them bottom-to-top.
Convert 131013_{10} to binary.
11011101.
Convert 201020_{10} to binary.
1010010100.
In repeated division, which remainder is the most significant bit?
The LAST remainder (when quotient reaches 0).
How many distinct values can nn bits represent, and what is the largest?
2n2^n values, from 00 to 2n12^n-1.
Largest value in 8 bits?
111111112=25511111111_2 = 255.
In counting, how often does each bit flip relative to the bit on its right?
Half as often (its weight is double).
Why does the remainder of N÷2N\div2 give the last binary bit?
It's 1 iff NN is odd; 202^0 is the only odd-weighted column.

Recall Feynman: explain to a 12-year-old

Imagine a row of light switches. Each switch is OFF or ON — that's all it can do. We say OFF means 0 and ON means 1. To count, the rightmost switch flips on every step. When it can't go higher (it's already ON), it turns OFF and "pokes" the switch to its left to flip — just like a car's mileage counter where 9 rolls over to 0 and bumps the next digit. To find what a row of switches means as a normal number, give each switch a value: the right one is worth 1, then 2, 4, 8, 16… (doubling each time). Add up the values of only the switches that are ON. That's the number!


Connections

  • Place-value and number bases — the general dibi\sum d_i b^i idea (binary is the b=2b=2 case).
  • Hexadecimal and Octal — shortcuts for writing long binary strings (base 16, base 8).
  • Bits and Bytes — a byte = 8 bits = values 0–255.
  • Logic gates and switcheswhy hardware is two-state.
  • Binary addition and overflow — counting/carry generalized to arithmetic.
  • Two's complement — how negative numbers reuse these bits.

Concept Map

two states means

10 levels too fragile

favors 2 states

generalizes any base

weights are powers of b

weights become

sum on-columns

example

repeated division

remainder gives

read remainders

Switches OFF or ON

Base 2 binary

Why not decimal hardware

Positional place-value

Weight equals b to the i

Powers of 2: 1,2,4,8...

Binary to Decimal

1011 equals 11

Decimal to Binary

Last bit d0 odd or even

Bottom-to-top order

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, computer ke andar sirf switches hote hain — ya toh OFF (0) ya ON (1). Bas do hi states. Isiliye computer ka apna number system base 2 yaani binary hai. Decimal (base 10) hum isliye use karte hain kyunki humare paas 10 ungliyaan hain, warna usme bhi koi magic nahi hai. Dono mein same "place-value" ka funda chalta hai: har position ka ek weight hota hai. Decimal mein weights hote hain 1, 10, 100… (das se multiply); binary mein weights hote hain 1, 2, 4, 8, 16… (do se multiply, har baar double).

Binary se decimal nikalna sabse easy hai: bit ke upar uska weight likho (20,21,222^0, 2^1, 2^2 \dots right se left), aur jahan-jahan bit 1 hai sirf wahi weights jod do. Jaise 101110118+0+2+1=118+0+2+1 = 11. Bas itna hi!

Decimal se binary ke liye "repeated division by 2" karo: number ko 2 se divide karte raho, har baar remainder (0 ya 1) note karo, aur quotient ko aage le jao jab tak 0 na aa jaye. Phir remainders ko neeche se upar padho — kyunki pehla remainder units wala bit hai (sabse chhota), aur aakhri remainder sabse bada (leftmost) bit. 1313 ko karo toh 11011101 aata hai, check: 8+4+1=138+4+1=13.

Counting toh bilkul gaadi ke meter jaisa hai — rightmost digit har step pe flip hota hai, jab woh ON se aage nahi ja sakta toh 0 ho ke left wale ko carry deta hai. Aur ek important baat: nn bits se aap 2n2^n alag values bana sakte ho, lekin sabse bada number 2n12^n-1 hota hai (kyunki ginti 0 se shuru hoti hai). 8 bits = 256 values, max = 255. Yeh off-by-one wali galti exam mein bahut log karte hain, isse bach ke rehna!

Go deeper — visual, from zero

Test yourself — How Computers Work

Connections