AP® Computer Science Principles · Big Idea 2 · Topic 2.1

Counting in Binary and Place Value

Binary counts using only two digits, 0 and 1, so each column's value is a power of two instead of a power of ten. A number's decimal value is just the sum of the place values where there's a 1.

Decimal has ten digits, 0 through 9, so a column fills up after 9 and rolls over, carrying a 1 into the next column worth ten times more. Binary only has two digits, 0 and 1. A column fills up after just 1, so it rolls over immediately and carries into the next column, which is worth two times more. That's the whole reason binary runs out so fast: there's nothing between 0 and 1 to count through.

Think of binary digits as an odometer with only two symbols per wheel. Starting at 0: 0, 1, then the ones wheel has no digit left, so it resets to 0 and carries a 1 into the next column, giving 10 (decimal two). Keep going: 11 (three), then both wheels are full, so both reset and a new column appears: 100 (four). This keeps happening every time a column of 1s would need to go higher, which is why 1111 (fifteen) rolls all the way over to 10000 (sixteen). Each column's place value is 2 raised to its position, counting the rightmost column as position 0: ...32, 16, 8, 4, 2, 1. To read a binary number, add up the place values wherever there's a 1 and skip the places with 0.

This place-value idea is the foundation for everything else in representing data as bits. Once you can convert between binary and decimal, you can see how a fixed number of bits limits how high a counter can go before it wraps around, and how groups of bits get reused later to represent colors, sound samples, and pixels.

Key terms

Bit
A single binary digit, either 0 or 1.
Place value
The value a digit contributes based on its position in the number.
Carry
Moving a 1 into the next column over when a column of digits is full and rolls over.
Power of two
A value of the form 2 raised to a whole number, such as 1, 2, 4, 8, 16, used as binary place values.

Watch it explained

  1. How it worksWalk me through counting from 0 up to 16 in binary like an odometer rolling its wheels over.
  2. How it worksHow does the place value of each binary column come from 2 raised to the position number?
  3. Worked exampleFind the decimal value of the binary number 10110 by adding up its place values.
  4. Worked exampleFind the binary value that comes right after 01111 when a 5-bit counter carries across every column.
  5. Common mistakeWhy isn't the binary number 10 equal to ten?

Check yourself

Your turn1 of 2
A binary number has a 1 in place value 23 and a 1 in place value 210, with all its other digits 0. What is this binary number's decimal value?

End of topic.