Skip to content
Now Accepting Applications for 2027-2028Apply
ITMagicITMagicAcademy
AP resources
APComputer ScienceCSP

Binary & Data Representation

AP Computer Science Principles — bits and bytes, converting between binary and decimal, and how numbers, text and images are represented digitally. Worked example and exam tip.

Everything a computer stores — numbers, text, images, sound — is ultimately binary: sequences of 0s and 1s. Understanding this "Data" big idea is central to AP Computer Science Principles (CSP).

Bits and bytes

  • A bit is a single 0 or 1.
  • A byte is 8 bits and can represent 2⁸ = 256 different values (0–255).
  • With n bits you can represent 2ⁿ distinct values.

Binary → decimal

Each place is a power of 2 (…, 8, 4, 2, 1):

1011₂ = 8 + 0 + 2 + 1 = 11₁₀

Decimal → binary

Subtract the largest fitting power of 2:

13 = 8 + 4 + 1 → 1101₂

Representing other data

  • Text: each character maps to a number (e.g. ASCII: 'A' = 65), then to binary.
  • Images: a grid of pixels; each pixel's colour is stored as RGB numbers (0–255 each).
  • Because storage is finite, large or precise values cause overflow (too big to store) or round-off (lost precision) errors.

Worked example

How many values can 4 bits represent, and what is the largest?

2⁴ = 16 values, from 0 to 15 (1111₂).

Exam tip

CSP tests concepts and abstraction, not heavy math. Know that more bits → more values (and more storage), why analog data must be sampled to become digital, and the difference between lossless and lossy compression. You will not need long hand-conversions under time pressure — you need the reasoning.

Interactive Simulation

Drag the sliders. See the change in real time.

00001011 = 11

Short Lesson Video

The lesson video for this topic will be added soon.

Mock Exam

The mock exam for this topic will be added soon.

Practice Quiz

Test yourself: instant results and explanations.

  1. 1. The binary number 1011 equals which decimal value?

  2. 2. How many different values can one byte (8 bits) represent?

  3. 3. The decimal number 13 written in binary is:

Need support with this topic?

In a free 30-minute intro call we assess your level and build a study plan tailored to you.

Free intro call