Binary Numbers (College Board AP® Computer Science Principles): Revision Note

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

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!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.