AP CSP 2.1 Binary Numbers | Bits, Bytes, and Binary to Decimal

AP CSP Course Big Idea 2 2.1 Binary Numbers
2.1
Big Idea 2 • Data

Binary Numbers

🕐 ~35 min FREE 📖 6 MCQ questions 🎮 Binary Conversion Race game DAT-1.A / DAT-1.B / DAT-1.C

After this lesson, you will be able to:

  • Define a bit and a byte and explain that computers represent all data as sequences of bits
  • Convert a binary number to decimal by summing the place values where a 1 appears
  • Convert a decimal number to binary using powers of 2 or repeated division by 2
  • Explain why n bits represent 2 to the n distinct values, and relate this to overflow
  • Distinguish analog from digital data and explain overflow and roundoff errors as limits of fixed bit-width
📈 Big Idea 2 (Data) is 17 to 22 percent of the AP CSP exam, and binary questions are among the most predictable points on the whole test. Conversions and the 2 to the n rule show up every year, and the analog versus digital and overflow versus roundoff ideas are quick vocabulary points once you can tell them apart.
💡 Think about this first

A single light switch can be off or on, which is exactly two states. String eight of those switches together and you can spell any letter, store a number up to 255, or set the shade of one pixel. Computers do not understand the number 42, a photo, or the word cat directly, yet all three end up as nothing but 0s and 1s. How can two symbols possibly be enough to represent everything a computer stores?

Bits, Bytes, and Why Two Symbols Are Enough

A bit is a binary digit: a single value that is either 0 or 1. It is the smallest unit of data a computer stores. A byte is a group of 8 bits. Computers represent all data — numbers, text, images, and sound — as sequences of bits. A photo, a song, and this sentence are all, underneath, just long strings of 0s and 1s. The meaning comes from how a program agrees to interpret those bits, not from the bits themselves.

Two symbols are enough because you combine them in a place-value system, the same idea you already use in base ten. In decimal you have ten digits and each place is worth ten times the one to its right. Binary is base 2: only two digits, and each place is worth twice the one to its right. Add more bits and you can count higher, exactly the way adding another decimal digit lets you count past 9.

🎯 What the exam rewards

Know the vocabulary cold: a bit is one 0 or 1, a byte is 8 bits, and every kind of data is stored as bits. A question that says a computer stores text or images "as binary" or "as sequences of bits" is stating a fact you are expected to already accept.

Binary Place Values and Converting to Decimal

Because binary is base 2, the place values are the powers of 2. Reading right to left they are 1, 2, 4, 8, 16, 32, 64, 128, and so on, each one double the last. To convert a binary number to decimal, write the place values above the bits and add up the place values wherever a 1 appears.

Place value 128 64 32 16 8 4 2 1
Binary digit 0 0 0 0 1 0 1 1

In the row above, 1s sit in the 8, 2, and 1 columns, so the value is 8 + 2 + 1 = 11. That is how you read the binary number 1011 as decimal 11. The reverse direction, decimal to binary, is covered next.

Quick check
Convert the binary number 1011 to decimal.

Converting Decimal to Binary

Two reliable methods give the same answer. Pick whichever you trust under time pressure.

  • Subtract the largest power of 2. Find the biggest power of 2 that fits, put a 1 there, subtract it, and repeat with what is left. For 37: 32 fits, leaving 5; 4 fits, leaving 1; 1 fits, leaving 0. Ones go in the 32, 4, and 1 columns, giving 100101.
  • Repeated division by 2. Divide by 2 and record each remainder. The remainders, read from bottom to top, are the binary digits. Dividing 37 gives remainders 1, 0, 1, 0, 0, 1 from last to first, which reads as 100101.

Check your work by converting back: 32 + 4 + 1 = 37. If the place values you marked do not add to the original decimal number, one of the bits is wrong.

⚠ Common trap

With the division method, students read the remainders in the order they wrote them and get the number backwards. The correct order is bottom to top (last remainder first). Always sanity-check by adding the place values back to the original decimal.

How Many Values Can n Bits Hold?

With n bits you can represent 2 to the n distinct values. Each bit doubles the count, because every existing pattern can now end in either a 0 or a 1. So 1 bit gives 2 values, 2 bits give 4, 3 bits give 8, and 8 bits (one byte) give 2^8 = 256 values. When those 256 values are used for whole numbers starting at zero, the range is 0 to 255, not 1 to 256.

Number of bits Distinct values (2 to the n)
1 2
2 4
4 16
8 (one byte) 256

This rule is the backbone of many exam questions. Adding a single bit does not add one more value, it doubles the number of values you can store.

Quick check
Using 3 bits, how many distinct values can you represent?

Analog vs Digital

Analog data changes smoothly and continuously, with infinitely many possible values between any two points — think of a dimmer knob sliding, a real sound wave, or a shadow lengthening through the afternoon. Digital data uses discrete values: a finite set of separate steps, stored as bits. To put analog information into a computer you take samples, measuring the signal at many moments and recording each measurement as a number.

A digital version is an approximation of the analog original, like a staircase tracing a ramp. The more samples you take and the more bits you use per sample, the closer the digital copy gets to the smooth original — but with a finite number of bits it can never be a perfect match.

🎯 What the exam rewards

Match the keyword to the concept: continuous means analog, discrete or sampled means digital. Expect a question where more samples and more bits per sample yield a closer approximation of an analog signal, never an exact one.

Limits of Fixed Bit-Width: Overflow and Roundoff

Because a computer sets aside a fixed number of bits for a value, some numbers simply do not fit, and the framework names two specific errors that result.

  • Overflow error: a value is too large to represent in the available bits. With 8 bits the largest whole number is 255; try to store 256 and there is no room, so the result is wrong.
  • Roundoff error: a value cannot be stored exactly and must be approximated or rounded. Many real numbers, such as the result of 1 / 3, would need infinitely many digits, so a fixed number of bits can only hold a rounded version.

The clean split: overflow is about a number being too big to fit at all; roundoff is about a number being impossible to store precisely, so it is stored close-but-not-exact. Both come from the same root cause, a finite number of bits.

⚠ Common trap

Do not swap the two. If a program adds 1 to the largest value a variable can hold and gets a nonsense result, that is overflow. If a program stores 0.1 or 1/3 and later the arithmetic is slightly off, that is roundoff. "Too large to represent" is overflow; "cannot be represented exactly" is roundoff.

Many Representations, Real Tradeoffs

The same information can be represented in more than one way, and the choice has consequences. The number eleven can be written as decimal 11 or binary 1011; both mean the same quantity. Using more bits per value widens the range you can store and reduces overflow and roundoff, but it also uses more memory and storage. Representations are chosen by weighing these tradeoffs, which is a theme you will see again in data compression.

💡 See it in action

Binary Place-Value Explorer
Click the bits. Watch the binary and the decimal update.
00000000=0
8 bits represent the values 0 to 255. Turn every bit on to reach 255.

How Binary Is Tested on the Exam

Binary number representation is multiple-choice material, not a skill you demonstrate on the Create Performance Task. You will not hand-convert numbers inside your Create Task program; instead the end-of-course multiple-choice exam asks you to convert between binary and decimal, apply the 2 to the n rule, and tell overflow apart from roundoff. Treat this as fast, high-confidence points.

Quick strategy for the exam room:

  • Write the place values first. Jot 128 64 32 16 8 4 2 1 across the top and line the bits up underneath. For binary to decimal, add the place values under each 1.
  • For decimal to binary, subtract the largest power of 2 that fits, mark a 1, and repeat with the remainder.
  • Always check by converting back. Add your marked place values; they must equal the original decimal number.
  • Sort the error type by keyword. "Too large to store" is overflow; "cannot be stored exactly" is roundoff.
📈
MCQ Practice
6 questions • Exam difficulty and above • Predict before you peek
Question 1 of 6Binary to decimal
Add the place values under each 1 before you look at the choices.

What is the decimal value of the binary number 1101?

Incorrect. 11 is binary 1011. In 1101 the 1s are in the 8, 4, and 1 columns.
Incorrect. 12 is binary 1100. The rightmost bit of 1101 is a 1, which adds one more.
Correct. 1101 has 1s in the 8, 4, and 1 columns, so the value is 8 + 4 + 1 = 13.
Incorrect. 14 is binary 1110. In 1101 the 2 column is 0, so you do not add 2.
Question 2 of 6Decimal to binary
Subtract the largest powers of 2 first, then match to an option.

What is the binary representation of the decimal number 37?

Incorrect. 101101 equals 32 + 8 + 4 + 1 = 45, not 37.
Correct. 37 = 32 + 4 + 1, so 1s go in the 32, 4, and 1 columns, giving 100101.
Incorrect. 110010 equals 32 + 16 + 2 = 50, not 37.
Incorrect. 100111 equals 32 + 4 + 2 + 1 = 39, not 37.
Question 3 of 6Multiple statements
Judge each statement true or false before choosing.

Consider these statements about how computers store data:

  • I. A byte consists of 8 bits.
  • II. With n bits a computer can represent 2 to the n distinct values.
  • III. Text and images are stored as sequences of bits, just like numbers.
Incorrect. Statements II and III are also true, not just I.
Incorrect. Statement III is true as well, so this option is incomplete.
Incorrect. Statement I is also true, so this pairing leaves out a correct statement.
Correct. All three are true: a byte is 8 bits, n bits give 2 to the n values, and all data types are stored as bits.
Question 4 of 6Overflow vs roundoff
Decide which error the keyword describes before reading the options.

A program uses a fixed number of bits for each whole number. It repeatedly adds 1 to a variable that already holds the largest value those bits can store, and the next result is a wrong, much smaller number. Which error does this best illustrate?

Correct. Exceeding the largest value the fixed bits can hold is an overflow error.
Incorrect. Roundoff is about a value that cannot be stored exactly, not about exceeding the maximum. Here the value was too large to fit.
Incorrect. The code runs; nothing is written incorrectly. The failure comes from the bit-width limit, which is overflow.
Incorrect. There is no such thing as an analog error here, and the data is already discrete whole numbers.
Question 5 of 6Bit-width and range
Work out how many values the bits give before scanning the choices.

A variable is stored using 8 bits and is used to hold whole numbers starting at 0. Which statement about this variable is correct?

Incorrect. There are 256 values, but starting at 0 the range is 0 to 255, not 1 to 256.
Incorrect. 128 is 2 to the 7. With 8 bits there are 2 to the 8 = 256 values.
Correct. 8 bits give 2 to the 8 = 256 values, and starting at 0 the range is 0 to 255.
Incorrect. The count of values is 256, not 255. The largest value is 255, but 0 is also a value, so there are 256 in total.
Question 6 of 6Analog vs digital
Predict what more samples do to a digital copy first.

An analog sound wave is recorded by measuring its height many times per second and storing each measurement as a number. Which statement best describes this digital recording?

Incorrect. A finite set of samples cannot capture every point of a continuous wave, so it is an approximation, not an exact copy.
Correct. Sampling produces a discrete approximation of the continuous signal, and more samples with more bits per sample bring it closer to the original.
Incorrect. Storing measurements as numbers makes the recording digital and discrete, even though the source was analog.
Incorrect. Digital data represents change fine by storing many samples over time; that is exactly how the recording works.
🎮 Lesson Game
Binary Conversion Race
Convert between binary and decimal against the clock and build speed for the exam.

Binary Conversion Race

AP CSP • Big Idea 2, Topic 2.1 - binary place value & decimal↔binary conversion.

How to play: beat the clock. Build numbers by toggling bits, or read a bit pattern and type its value. Correct answers grow your streak for bonus points.

Time
60
Score
0
Streak
0
Best
0

Ready to race?

60 seconds. Two round types alternate: Build the number and Read the bits.

The place-value header (128 64 32 16 8 4 2 1) stays on screen the whole time to guide you.

Build the number

Make this decimal in binary:

42

Time!

0
0Best streak
0Correct

Nice work!

Frequently Asked Questions

A bit is a single binary digit, either 0 or 1, and is the smallest unit of data. A byte is a group of 8 bits. Computers represent all data, including numbers, text, images, and sound, as sequences of bits.
Write the place values 128 64 32 16 8 4 2 1 above the bits, then add up the place values everywhere a 1 appears. For example, 1011 has 1s in the 8, 2, and 1 columns, so it equals 8 + 2 + 1 = 11.
With n bits you can represent 2 to the n distinct values, because each bit doubles the number of patterns. Eight bits give 2 to the 8 = 256 values. When used for whole numbers starting at 0, that range is 0 to 255.
Overflow happens when a value is too large to represent in the available bits, such as going past the maximum a variable can hold. Roundoff happens when a value cannot be stored exactly, like many real numbers, so it is approximated. Overflow is too big to fit; roundoff is impossible to store precisely.
Analog data changes smoothly and continuously with infinitely many possible values. Digital data uses discrete, separate values stored as bits. Analog signals are turned into digital data by sampling, and more samples with more bits per sample give a closer approximation of the original.
📦
AP CSP Teacher SuperpackSlides, lesson plans, unit tests for all 5 Big Ideas, $249
Get the Superpack →
🏫
For teachers

Binary is where students either click or freeze, so drill the place-value strip until conversions are automatic, then time them with the Binary Conversion Race game before the exam. The overflow versus roundoff distinction is a reliable point students miss, so anchor it with a keyword sort: too large to fit means overflow, cannot be stored exactly means roundoff. The Superpack includes conversion worksheets and an analog-to-digital sampling demo. View what's included →

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]