← Binary Course — Part A, lesson 2 of 4 (Counting in other bases)

2. Binary: Place Value With Only Two Digits

LESSON 2 | 0000 0010 | 0x02

The concept

Decimal place value works by giving each position in a number its own weight, ten times bigger than the position to its right, and allowing any digit 0-9 in each position. The number 372 isn't three separate symbols — it's 3×100 + 7×10 + 2×1, three hundreds, seven tens, two ones.

Binary place value works exactly the same way, with two changes: each position is only twice as big as the position to its right (not ten times), and each position can only hold a 0 or a 1, never anything higher. That's the entire idea — nothing about place value itself changes, only how many different digits are allowed at each position and how fast the weights grow.

This lesson numbers bit positions, so it's worth fixing the convention before using it: bit 0 is the rightmost bit, and indices increase to the left. For an 8-bit number (this course's default width), the positions and their place values are:

bit index:     7    6    5    4    3    2    1    0
place value:  128   64   32   16    8    4    2    1

Each place value is double the one before it, because moving one position left in any place-value system multiplies the weight by that system's base — base 10 for decimal, base 2 for binary. To read a binary number's decimal value, add up the place values of every position that holds a 1 and ignore the positions holding a 0. To build a binary number from a decimal value, find which powers of two sum to it and set exactly those bits to 1.

Example 1 — counting up in binary (the carry pattern)

To see the carry pattern clearly, this example drops to 4 bits (place values 8, 4, 2, 1) rather than this course's usual 8-bit default — a smaller case makes the pattern easier to see.

Decimal counting carries into a new column whenever a column fills past its highest digit: 9 → 10, 19 → 20, 99 → 100. Binary does the same thing, it just happens far more often, because a column "fills up" after only one step instead of nine:

decimal   binary
   0      0000
   1      0001
   2      0010   (bit 0 filled at 1, so it carries: bit 1 turns on, bit 0 resets)
   3      0011
   4      0100   (bits 0 and 1 both filled, so it carries twice: bit 2 turns on, bits 1-0 reset)
   5      0101
   6      0110
   7      0111
   8      1000   (bits 0-2 all filled, so it carries three times: bit 3 turns on, bits 2-0 reset)

The mechanism is identical to decimal carrying — a position that can't hold one more resets to 0 and adds one to the position on its left. Binary just resets after every single digit (0 or 1, nothing higher), so carries ripple much more often than in decimal (0 through 9).

Example 2 — reading a binary number's value

Take the 8-bit number 0110 1101. Line it up under the place-value table and add up only the positions holding a 1:

bit index:     7    6    5    4    3    2    1    0
bit:           0    1    1    0    1    1    0    1
place value:  128   64   32   16    8    4    2    1

Bits 6, 5, 3, 2, and 0 hold a 1. Their place values are 64, 32, 8, 4, and 1:

64 + 32 + 8 + 4 + 1 = 109

0110 1101 is 109.

Example 3 — building a binary number from a decimal value

Take 173 and go the other direction: at each position from bit 7 down to bit 0, ask "does this position's place value fit into what's left?" If yes, set that bit to 1 and subtract; if no, set it to 0 and move on.

place value 128:  128 ≤ 173 → bit 7 = 1, remainder 173 − 128 = 45
place value  64:   64 ≤  45? no  → bit 6 = 0
place value  32:   32 ≤  45 → bit 5 = 1, remainder 45 − 32 = 13
place value  16:   16 ≤  13? no  → bit 4 = 0
place value   8:    8 ≤  13 → bit 3 = 1, remainder 13 − 8 = 5
place value   4:    4 ≤   5 → bit 2 = 1, remainder 5 − 4 = 1
place value   2:    2 ≤   1? no  → bit 1 = 0
place value   1:    1 ≤   1 → bit 0 = 1, remainder 1 − 1 = 0

Reading the bits from bit 7 down to bit 0 gives 1010 1101. Check it against Example 2's method: 128 + 32 + 8 + 4 + 1 = 173. Correct.

Exercises

Exercise 1. Using Example 2's method, what decimal value does the 8-bit binary number 0100 1011 represent?

Exercise 2. Take Exercise 1's number, 0100 1011. Suppose a single bit gets misread — the kind of single-digit misread Lesson 1 said a computer must avoid. First, suppose bit 3 gets misread as a 1 instead of a 0 (so the number becomes 0100 1111): how much does the decimal value change? Now suppose instead bit 6 gets misread as a 1 instead of a 0 (0110 1011): how much does the decimal value change this time? Why does misreading bit 6 cost so much more than misreading bit 3, even though both are just "one wrong bit"?

Exercise 3. A classmate converts 0110 1101 (Example 2's number) and gets 182 instead of 109. Their work: they wrote the place values 1 2 4 8 16 32 64 128 under the bits left to right, matched them up, and added the place values under every 1. What did they get wrong, and what's the correct value?

Show Answer Key

1. Bits 6, 3, 1, and 0 hold a 1, with place values 64, 8, 2, and 1: 64 + 8 + 2 + 1 = 75.

2. Flipping bit 3 changes the value by its place value, 8: 75 + 8 = 83, a change of 8. Flipping bit 6 changes the value by its place value, 64: 75 + 64 = 139, a change of 64. Both are equally "one wrong bit," but they don't cost the same, because place value isn't uniform across positions — a bit's place value depends on where it sits, and a higher-index bit is worth far more than a lower-index one. A single misread near the front of a binary number can be a much larger error than the same kind of misread near the back, even though the underlying mistake (one bit, wrongly read) is identical in both cases.

3. They assigned place values as if bit 0 were the leftmost bit instead of the rightmost — the opposite of the convention this lesson stated at the start. Reversing the place-value order changes which weight lands on which bit, which changes the total. Matching place values to bits correctly (128 under the leftmost bit, 1 under the rightmost, per the bit-index table in Example 2) gives 64 + 32 + 8 + 4 + 1 = 109, the correct value.