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.