Binary — Place Value in Powers of Two
Deep down, a computer stores everything as switches that are either off or on. To store the number 13, it needs a way to write 13 using only two symbols. The answer is the same place-value idea you already use for decimal, with one change: each place is worth double the one to its right instead of ten times.
The rule
Each bit is worth double the bit on its right.
A bit is one binary digit: 0 or 1. Reading from the right, the places are worth 1, 2, 4, 8, 16, 32, 64, 128 and so on. A 1 means "include this value"; a 0 means "skip it".
place value: 8 4 2 1
bits: 1 0 1 1
8 +0 +2 +1 = 11So binary 1011 is decimal 11. Programmers often write 0b1011 to make the base clear.
Eight bits make a byte. With n bits there are 2ⁿ different patterns, so a byte holds 2⁸ = 256 patterns, the numbers 0 to 255. The largest value with n bits is always 2ⁿ − 1, all ones: 11111111 = 255.
The shortcut
Binary to decimal: add up the place values sitting under the 1s.
Decimal to binary: take the biggest power of two that fits, subtract, and repeat with what is left. Every power you take becomes a 1; every one you skip becomes a 0.
Biggest power that fits
16 fits into 25 and 32 does not. Take 16: 9 left.
The trap is reading binary like decimal. 10 in binary is two, not ten, and 100 is four. Always read the places, never the digits as a whole.
Drills
Answer fast — trust the rule.
What is binary 10110 in decimal?
What is 13 in binary?
What is the largest number one byte (8 bits) can hold without a sign?
How many different values can 10 bits represent?
Remember
- Each bit is worth double the one to its right: 1, 2, 4, 8, 16, …
- To convert, add the place values under the 1s, or peel off the biggest powers of two.
- The trap: n bits hold 2ⁿ values, but the biggest is 2ⁿ − 1.
