Binary Numbers (College Board AP® Computer Science Principles): Revision Note
Number systems & base conversion
What are number systems?
A number base defines how many unique digits are used to represent values in a system
Decimal (base 10) uses ten digits: 0 to 9
Binary (base 2) uses two digits: 0 and 1
Any value that can be represented in decimal can also be represented in binary, and vice versa
Conversion between number bases is the process of expressing the same value in a different representation
Converting decimal to binary
Divide the decimal number by 2 repeatedly
Record the remainder (0 or 1) at each step
Read the remainders from bottom to top to get the binary value
Example: convert 45 to binary
Step | Division | Result | Remainder |
|---|---|---|---|
1 | 45 ÷ 2 | 22 | 1 |
2 | 22 ÷ 2 | 11 | 0 |
3 | 11 ÷ 2 | 5 | 1 |
4 | 5 ÷ 2 | 2 | 1 |
5 | 2 ÷ 2 | 1 | 0 |
6 | 1 ÷ 2 | 0 | 1 |
Reading the remainders from bottom to top: 101101
45 in decimal = 101101 in binary
Converting binary to decimal
Write out the place value for each bit position (powers of 2, right to left)
Multiply each binary digit by its place value
Add the results together
Example: convert 11010110 to decimal
Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
Binary digit | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
Calculation | 128 | 64 | 0 | 16 | 0 | 4 | 2 | 0 |
128 + 64 + 16 + 4 + 2 = 214
11010110 in binary = 214 in decimal
Place value & calculations
How does place value work in binary?
Each position in a binary number has a place value equal to a power of 2
The rightmost position is 2^0 (= 1), the next is 2^1 (= 2), then 2^2 (= 4), and so on
The base of the number system determines the exponent pattern: in binary, each position is worth twice as much as the position to its right
Position (right to left) | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Example: convert 10010011 to decimal
Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
Binary digit | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
Calculation | 128 | 0 | 0 | 16 | 0 | 0 | 2 | 1 |
128 + 16 + 2 + 1 = 147
10010011 in binary = 147 in decimal
Examiner Tips and Tricks
Binary conversion questions appear frequently on the AP exam. Practice both directions (decimal to binary and binary to decimal) until the process is automatic. When converting binary to decimal, write out the place value table first, then add the values where the digit is 1. This structured approach reduces errors under time pressure.
For the AP Create Performance Task, your program may store or process numerical data — understanding how numbers are represented in binary helps you anticipate overflow and rounding issues covered in the previous note.
Worked Example
What is the decimal value of the binary number 10110?
(A) 18
(B) 22
(C) 26
(D) 30
[1]
Answer:
(B) 22 [1 mark]
Reading 10110 from left to right gives place values 1 × 16, 0 × 8, 1 × 4, 1 × 2, 0 × 1 = 16 + 4 + 2 = 22
Unlock more, it's free!
Was this revision note helpful?