# 2.1 Binary Numbers

## Enduring Understanding

The way a computer represents data internally is different from the way the data are interpreted and displayed for the user. Programs are used to translate data into a representation more easily understood by people.

## Learning Objective

Explain how data can be represented using bits.

## Essential Knowledge

Data values can be stored in variables, lists of items, or standalone constants and can be passed as input to (or output from) procedures.

Computing devices represent data digitally, meaning that the lowest-level components of any value are bits.

Bit is shorthand for binary digit and is either 0 or 1.

A byte is 8 bits.

Abstraction is the process of reducing complexity by focusing on the main idea. By hiding details irrelevant to the question at hand and bringing together related and useful details, abstraction reduces complexity and allows one to focus on the idea.

Bits are grouped to represent abstractions. These abstractions include, but are not limited to, numbers, characters, and color.

The same sequence of bits may represent different types of data in different contexts.

Analog data have values that change smoothly, rather than in discrete intervals, over time. Some examples of analog data include pitch and volume of music, colors of a painting, or position of a sprinter during a race.

The use of digital data to approximate real world analog data is an example of abstraction.

Analog data can be closely approximated digitally using a sampling technique, which means measuring values of the analog signal at regular intervals called samples. The samples are measured to figure out the exact bits required to store each sample.

## Learning Objective

Explain the consequences of using bits to represent data. 

## Essential Knowledge

In many programming languages, integers are represented by a fixed number of bits, which limits the range of integer values and mathematical operations on those values. This limitation can result in overflow or other errors.

Other programming languages provide an abstraction through which the size of representable integers is limited only by the size of the computer’s memory; this is the case for the language defined in the exam reference sheet.

In programming languages, the fixed number of bits used to represent real numbers limits the range and mathematical operations on these values; this limitation can result in round-off and other errors. Some real numbers are represented as approximations in computer storage.

{% hint style="info" %}
Exclusion Statement: Specific range limitations for real numbers are outside the scope of this course and the AP Exam.
{% endhint %}

## Learning Objective

For binary numbers:

a. Calculate the binary (base 2) equivalent of a positive integer (base 10) and vice versa. 

b. Compare and order binary numbers. 

## Essential Knowledge

Number bases, including binary and decimal, are used to represent data.

Binary (base 2) uses only combinations of the digits zero and one.

Decimal (base 10) uses only combinations of the digits 0 – 9.

As with decimal, a digit’s position in the binary sequence determines its numeric value. The numeric value is equal to the bit’s value (0 or 1) multiplied by the place value of its position.

The place value of each position is determined by the base raised to the power of the position. Positions are numbered starting at the rightmost position with 0 and increasing by 1 for each subsequent position to the left.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.csprinciples.com/big-idea-2/2.1-binary-numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
