Now readingIntroduction
0%
AP Computer Science Principles · Framework 2026-27
Unit 2

Data

Digital data use bits to represent numbers, text, images, sound, and sampled approximations of analog signals. Compression changes storage or transmission size, while metadata and documented transformations help organize and interpret data.

Exam weight
17–22% of multiple choice
Topics
4

Introduction

Digital data use bits to represent numbers, text, images, sound, and sampled approximations of analog signals. Compression changes storage or transmission size, while metadata and documented transformations help organize and interpret data.

The technical calculation is only half of the work. State the representation, cleaning and combination rules, tools, sample size, and limits imposed by collection. Keep “what the program calculated” separate from “what the result justifies,” especially when association, bias, or scalability matters.

Current exam guidance: Aligned to the Fall 2023 AP CSP framework used in 2026–27. The May 14, 2027 digital exam includes 70 multiple-choice questions in 120 minutes plus two Create-related written-response questions in 60 minutes. The Create components are due April 30, 2027 at 11:59 p.m. ET; current College Board directions always control submission policy.
2.1

Binary Numbers

How do bits represent numbers and approximate other kinds of data?

Short answer

A bit is a zero or one; groups of bits become useful only through an agreed interpretation, such as binary place value for a number or sampled values for an analog signal.

Know firstDecimal place value · Powers of two

Read binary as weighted place value

Binary uses the same place-value idea as decimal with a different base. Starting at the right, the position weights are 1,2,4,8,16,1, 2, 4, 8, 16, and so on. In 10110, the one-bits select 16, 4, and 2, giving 22. Leading zeros do not change the value, and comparing equal-width nonnegative binary numbers begins with the leftmost position where they differ.

Bits have no meaning without a representation rule. The same pattern might encode a number, character, color component, or part of a sound. A byte contains eight bits. Real-world quantities such as sound pressure change continuously; a device approximates them by sampling at discrete times and storing a finite approximation for each sample. More frequent or more precise samples can preserve additional detail but require more data.

A fixed-width unsigned representation using kk bits has 2k2^k patterns, from 0 through 2k−12^k-1. Five bits therefore represent 0 through 31; 32 needs a sixth bit under that model. Fixed numeric ranges can cause overflow, and finite real-number representations can cause round-off. The AP Exam Reference Sheet language instead treats integer size as limited by available memory, so do not invent a fixed-width overflow unless a prompt supplies one.

AP pseudocode trace

Convert 10110 by accumulating active weights

bits ← [1, 0, 1, 1, 0]
weights ← [16, 8, 4, 2, 1]
value ← 0
index ← 1
REPEAT 5 TIMES
{
  value ← value + bits[index] * weights[index]
  index ← index + 1
}
DISPLAY(value)
Execution stateStep 1 of 5
position
1
bit
1
weight
16
runningValue
16
Open complete trace table
Complete trace states
SteppositionbitweightrunningValue
1111616
220816
331420
441222
550122
Output
22

The active weights are sixteen, four, and two. Their running total is sixteen, twenty, then twenty-two; zero-bits contribute nothing.

Convert without treating bits as decimal digits

  1. Identify what the bit pattern represents before interpreting it.
  2. For a nonnegative integer, write powers of two from right to left and add the active weights.
  3. For sampled analog data, distinguish sampling frequency from the precision of each stored sample.
  4. Apply a finite-range or round-off limit only when the representation defines one.

Keep these three ideas

  • A representation rule gives bits meaning.
  • Binary place values are powers of two.
  • Sampling, finite width, and finite precision introduce different limits.

Keep reading Unit 2: Data

You just read the first topic free. Your free trial opens the rest of this unit, every AP Computer Science Principles unit, and all 19 AP courses.

  • 2.1 Binary NumbersRead
  • 2.2 Data Compression
  • 2.3 Extracting Information from Data
  • 2.4 Using Programs with Data
Start my free 7 days →$0.00 due today · cancel anytime · score guarantee

Practice AP Computer Science Principles in the real test engine.

Free practice set: timed, the same engine as our full-length tests, every answer explained.