---
title: "Big Idea 2: Binary, Numbers & Representation | FiveStudy"
description: "Comprehensive study guide for AP Computer Science Principles. Free on FiveStudy."
url: https://fivestudy.com/guides/binary-numbers-representation
---

[AP Computer Science Principles](https://fivestudy.com/ap-computer-science-principles) · Study guide

# Big Idea 2: Binary, Numbers & Representation

[Figure: FiveStudy logo]

FiveStudy

Big Idea 2 · Part 1

Big Idea 2 · Data · Part 1 of 2

# Binary, Numbers & *Representation*

How computers store everything as bits, converting between binary and decimal, counting what n bits can represent, and the limitations that cause overflow and round-off errors.

## §1 What Big Idea 2 Covers

Big Idea 2 (DAT) is about how computers store data and how people pull meaning out of it. Every piece of information a computer handles — a number, a letter, a photo, a song — is ultimately stored as bits.

The exam tests four clusters:

- **Binary representation** — how bits represent numbers, text, images, and sound.
- **Limitations** — overflow, round-off, and why they happen.
- **Compression** — lossless vs. lossy, and when each is appropriate.
- **Metadata and information extraction** — what you can and cannot learn from a data set.

Part 1 covers binary, representation, and limitations. Part 2 covers compression, metadata, and data extraction.

Exam weight

Big Idea 2 accounts for **17–22% of the multiple-choice exam**. The exam does not test obscure conversions — it tests whether you can convert small binary numbers, estimate how many bits are needed, and reason about data limitations.

## §2 Bits and Bytes

A **bit** is a single binary digit: 0 or 1. A **byte** is 8 bits. Everything a computer stores is encoded as sequences of bits.

## §3 Binary ↔ Decimal Conversion

### 3.1 Binary to Decimal

Each bit position represents a power of 2, starting from 2⁰ on the right:

| Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| **Place value** | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

To convert: add the place values wherever a 1 appears.

Worked example · Binary → Decimal

Convert **10110101** to decimal:

| Bit | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| **Value** | 128 | — | 32 | 16 | — | 4 | — | 1 |

Sum: 128 + 32 + 16 + 4 + 1 = **181**

### 3.2 Decimal to Binary

Start with the largest power of 2 that fits. Subtract it, write a 1, and repeat. Write 0s for powers that don't fit.

Worked example · Decimal → Binary

Convert **45** to binary:

45 ≥ 32? Yes → 45 − 32 = 13 → write **1**
13 ≥ 16? No → write **0**
13 ≥ 8? Yes → 13 − 8 = 5 → write **1**
5 ≥ 4? Yes → 5 − 4 = 1 → write **1**
1 ≥ 2? No → write **0**
1 ≥ 1? Yes → 1 − 1 = 0 → write **1**

Answer: **101101**

## §4 Counting Representations

With *n* bits, you can represent **2ⁿ** unique values.

Memorize at least 2¹ through 2¹⁰. Know that 2¹⁰ = 1024 ≈ 1000.

### 4.1 Minimum Bits Needed

To find the minimum bits needed for *k* unique values, find the smallest *n* with 2ⁿ ≥ k.

Worked example

A class has 54 students. Minimum bits for a unique ID?

2⁵ = 32 (too few). 2⁶ = 64 ≥ 54. Answer: **6 bits**.

### 4.2 Comparing Binary Numbers

To compare binary numbers of equal length, compare from left (most significant bit) to right. The first position where they differ determines which is larger.

Key rule

**10000000** (= 128) is greater than **01111111** (= 127), even though 01111111 has more 1s. The leftmost bit dominates.

## §5 Representing Different Data Types

Everything a computer stores is bits. The *interpretation* of those bits depends on what kind of data they represent.

| Type | How it's represented |
| --- | --- |
| **Integer** | Direct binary. The leftmost bit often indicates sign. |
| **Real number** | A fixed number of bits approximates the value. Some real numbers cannot be represented exactly. |
| **Text** | Each character is assigned a number (e.g., ASCII), stored in binary. |
| **Image** | Each pixel stores color values (typically R, G, B). Bits per pixel determines how many colors are possible. |
| **Sound** | The analog wave is sampled at regular intervals; each sample is stored as a number. |

### 5.1 Color Depth

An image uses a fixed number of bits per pixel to represent color. *n* bits per pixel = 2ⁿ possible colors.

Common pitfall

Adding 1 bit *doubles* the number of representable values — it doesn't add 1. Going from 8-bit to 16-bit color gives 2¹⁶ / 2⁸ = 2⁸ = **256 times** as many colors — not twice as many, not 8 times as many.

## §6 Overflow and Round-Off Errors

### 6.1 Overflow Errors

An **overflow error** happens when a calculation produces a number too large for the fixed number of bits used to store it.

Worked example

A system uses 8 bits for unsigned integers (range: 0–255). Adding 200 + 100 = 300 causes overflow because 300 > 255. The result is wrong — it doesn't crash, it wraps around to a garbage value.

### 6.2 Round-Off Errors

A **round-off error** happens when a real number cannot be represented exactly in a fixed number of bits, so it's stored as an approximation.

Worked example

In a program, (0.1 + 0.2) often equals 0.30000000000000004, not 0.3. This happens because 0.1 and 0.2 are infinite repeating fractions in binary — the system truncates them, and the tiny errors don't perfectly cancel.

Definition · Overflow vs. Round-Off

**Overflow** happens with *integers that are too big* for their storage.

**Round-off** happens with *real numbers that can't be written exactly* in binary.

They are different errors. The exam distinguishes between them, and so should you.

## §7 Exam Patterns

### 7.1 Binary conversion

Use the place-value table. For "which binary number is largest," compare from left to right.

### 7.2 "How many bits are needed?"

Find the smallest n with 2ⁿ ≥ k. Remember 2¹⁰ = 1024 ≈ 1000 as a landmark.

### 7.3 "More colors available" (scaling)

Going from m-bit to n-bit color gives 2⁽ⁿ⁻ᵐ⁾ times as many colors — not (n − m) times.

### 7.4 Overflow vs. Round-off

Big integer result → overflow. Fractional value that can't be written exactly → round-off. Never mix them up.

## §8 Key Terms

| Term | Definition |
| --- | --- |
| **Analog data** | Continuous data (e.g., real-world sound waves) |
| **Binary** | Base-2 number system using only 0 and 1 |
| **Bit** | A single binary digit (0 or 1) |
| **Byte** | 8 bits |
| **Digital data** | Data represented using discrete values (bits) |
| **Overflow error** | Error from a value too large for its bit storage |
| **Pixel** | A single dot in a digital image |
| **Round-off error** | Error from a real number being approximated in limited bits |
| **Sampling** | Measuring a continuous signal at regular intervals to digitize it |

## §9 Self-Check

1. Convert 11001010 to decimal.
2. Convert 77 to binary.
3. How many unique values can 10 bits represent? What is the minimum number of bits needed for 1000 unique values?
4. Which is larger: 10000001 or 01111110? By how much?
5. A program uses 8 bits for unsigned integers. What happens when it computes 200 + 80? What type of error is this?
6. A program evaluates (0.1 + 0.2 − 0.3) and gets 5 × 10⁻¹⁷ instead of 0. What type of error and why?
7. A photo editor offers 8-bit or 24-bit color. How many times as many colors does 24-bit provide?

**Show Answers**

1. 128 + 64 + 8 + 2 = **202**.
2. 77 = 64 + 8 + 4 + 1 → **1001101**.
3. 2¹⁰ = **1024** unique values. For 1000 values: 2⁹ = 512 < 1000, 2¹⁰ = 1024 ≥ 1000, so minimum is **10 bits**.
4. 10000001 = 129; 01111110 = 126. The first is larger by **3**.
5. 200 + 80 = 280 > 255, so **overflow** occurs. The result wraps around to a wrong value.
6. **Round-off error.** 0.1, 0.2, and 0.3 cannot be represented exactly in binary floating-point. Each is stored as an approximation, and the tiny errors don't perfectly cancel.
7. 2²⁴ / 2⁸ = 2¹⁶ = **65,536 times** as many.

FiveStudy · AP Computer Science Principles · 2025–26

BI2 Part 1 · Binary & Representation
