AP Computer Science Principles · Unit 2: Data
2.1 Binary Numbers
Why binary?
Computers store and process data using binary numbers, a base-2 system with only two digits: 0 and 1. Each digit is called a bit. Binary works well for computers because digital circuits can easily represent two states — on/off, high/low voltage — making it a reliable way to encode information.
Converting binary to decimal
Each bit position represents a power of 2, starting from 2^0 on the right. To convert binary to decimal, multiply each bit by its place value and sum the results. For example, 1011 = (1×8)+(0×4)+(1×2)+(1×1) = 11 in decimal.
Limits and overflow
A binary number with n bits can represent 2^n distinct values, ranging from 0 to 2^n − 1. If a calculation produces a value too large for the available bits, it causes overflow, where the extra bits are lost and the stored value becomes incorrect.
Key terms
- Binary number system
- A base-2 number system that uses only the digits 0 and 1 to represent data.
- Bit
- The smallest unit of data in computing, representing a single binary digit (0 or 1).
- Converting binary to decimal
- Multiply each bit by its place value (a power of 2) and sum the results.
- Number of values with n bits
- 2^n distinct values can be represented, ranging from 0 to 2^n − 1.
- Overflow
- An error that occurs when a computed value is too large to be represented with the available number of bits, causing incorrect results.
Try an AP-style question
What is the binary number 1011 in decimal?
- 10
- 1011
- 13
- 11
Show the answer
D. 8 + 0 + 2 + 1.
Practice 8 AP-style questions with instant explanations, flashcards and spaced review.
Study 2.1 free in APrep