Binary Numbers

Chloe Evans
9 min read
Listen to this study note
Study Guide Overview
This AP Computer Science Principles study guide covers data representation concepts, including: number bases (decimal, binary, hexadecimal), bit representation (ASCII and Unicode), abstraction, analog vs. digital data (sampling), and overflow/rounding errors. It also provides practice questions and exam tips.
AP Computer Science Principles: Data Representation Study Guide
Hey there! Let's get you prepped for the AP CSP exam. This guide is designed to be your go-to resource, especially the night before the test. We'll break down the key concepts, highlight important connections, and make sure you're feeling confident. Let's do this!
๐พ Data Basics and Number Systems
What is Data?
Data is simply a collection of facts. It's everywhere, from lab results to your favorite videos. Computers run on data, but how do they store it? Let's dive in!
How Computers Store Data
Computers store data in bits, which are binary digits (0s and 1s). To understand this, we need to talk about number bases.
Number Bases
A number base is the number of digits or digit combinations a system uses to represent values.
- Decimal (Base-10): Uses 0-9. This is what we use in everyday life.
- Binary (Base-2): Uses only 0 and 1. This is what computers use at their core.
- Hexadecimal (Base-16): Uses 0-9 and A-F. Often used for color codes and representing binary in a more human-friendly way.
Computers use binary (base-2) at their core, but we often use hexadecimal (base-16) to represent binary values in a more human-friendly way.
Decimal System (Base-10)
Remember place values? Ones, tens, hundreds, thousands, etc. Each place is a power of 10.
For example, 5,729 = (5 x 1000) + (7 x 100) + (2 x 10) + (9 x 1)
Binary System (Base-2)
Each place can only hold a 0 or 1. The place values are powers of 2: ones, twos, fours, eights, etc.
For example, binary 0101 = (0 x 8) + (1 x 4) + (0 x 2) + (1 x 1) = 5
Binary Place Values: Remember the powers of 2: 1, 2, 4, 8, 16, 32, 64, 128... Each 'place' in a binary number represents one of these values.
- Bit: A single binary digit (0 or 1).
- Byte: 8 bits.
Hexadecimal System (Base-16)
Uses 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Place values are powers of 16.
For example, 1661 = (1 x 4096) + (6 x 256) + (6 x 16) + (1 x 1) = 5,729
The AP CSP test may ask you to convert between binary, decimal, and hexadecimal. Practice these conversions!
โ๏ธ Bit Representation
Bits can represent numbers, text, colors, and more. The same bit sequence can mean different things depending on the context.
ASCII and Unicode
ASCII is a standard for converting text to binary. Unicode is a more modern and comprehensive system.
For example, the binary code for the letter 'A' is the same as the decimal number 65. Programs know how to interpret the bit sequence based on the context.
Same sequence of bits can represent different types of data based on context. For example, 01000001 can be the letter 'A' or the number 65.
Why Don't We See Binary All the Time? Abstraction!
We don't deal with 0s and 1s directly because of abstraction.
๐ญ Abstraction
Abstraction simplifies complex systems by hiding unnecessary details. It allows us to focus on the main idea without getting bogged down in the specifics.
Abstraction in Everyday Life
Think of your oven's start button. You don't need to know how the oven works internally to use it. You just press the button, and it heats up. This is abstraction in action.
Abstraction in Computing
Computers use bits, but we interact with them through variables, lists, spreadsheets, and charts. These are all abstractions that hide the complex binary processes.
Abstraction is crucial in computer science. It allows us to use complex systems without needing to understand all the underlying details.
๐ Analog vs. Digital Data
Analog Data
Analog data is continuous and changes smoothly. Examples include the volume of music, the time on an analog clock, and the temperature on a mercury thermometer.
Digital Data
Digital data is discrete and has a finite set of possible values. It's created by sampling analog data at regular intervals. Digital data is an approximation of analog data.
Think of a digital clock (discrete) vs. an analog clock (continuous). Digital data is like a series of snapshots, while analog data is like a continuous video.
Sampling
Analog data is converted to digital data through sampling. The values of the analog signal are measured and recorded at regular intervals. The number of bits used for each sample determines the precision of the digital representation.
Why Digital is an Abstraction
Digital data simplifies real-world information. It's a finite representation of something that is continuous. This simplification is another example of abstraction.
โ ๏ธ Overflow Errors and Rounding
Overflow Errors
In low-level languages, numbers are stored using a fixed number of bytes. This limits the range of values that can be stored.
For example, an 8-bit byte can store values from 0 to 255. If you try to store a number larger than 255, an overflow error occurs. This can result in unexpected negative numbers or incorrect values.
Overflow errors happen when you try to store a number that's too big for the allocated memory space. Watch out for this when dealing with fixed-size data types.
Rounding Errors
Because computers store numbers with a limited number of bits, they sometimes round or cut off numbers. This is especially noticeable with repeating decimals.
For example, 100/3 might be displayed as 33.333333 instead of the full repeating decimal. This is another form of abstraction.
Be aware of overflow and rounding errors. They are common sources of bugs in programs and can lead to unexpected results.
๐ฏ Final Exam Focus
Here's what to focus on for the exam:
- Number Bases: Be able to convert between binary, decimal, and hexadecimal.
- Bit Representation: Understand how bits represent different types of data.
- Abstraction: Know how abstraction simplifies complex systems and hides details.
- Analog vs. Digital: Understand the difference and how analog data is converted to digital.
- Overflow and Rounding Errors: Be aware of these limitations of digital representation.
Last-Minute Tips
- Time Management: Don't spend too long on one question. If you're stuck, move on and come back later.
- Common Pitfalls: Watch out for those overflow and rounding errors! They're tricky.
- FRQs: Make sure to explain your reasoning clearly. Partial credit is your friend!
๐ Practice Questions
Practice Question
Multiple Choice Questions
-
What is the decimal representation of the binary number 101101? (A) 45 (B) 46 (C) 47 (D) 48
-
Which of the following is NOT an example of abstraction? (A) Using a function in a program without knowing its code. (B) Driving a car without knowing how the engine works. (C) Directly manipulating bits in computer memory. (D) Using a high-level programming language instead of assembly language.
-
What is the hexadecimal representation of the decimal number 255? (A) FF (B) FE (C) FA (D) FB
Free Response Question
Scenario: A sensor records temperature data every second. The temperature is an analog value, and the sensor converts it to a digital representation using 8 bits for each reading. The sensor records the following temperature readings (in Celsius) over 5 seconds: 25.3, 25.7, 26.1, 26.4, 26.8. (a) Explain how the analog temperature data is converted to digital data using a sampling technique.
(b) What is the maximum number of distinct temperature values that can be represented using 8 bits?
(c) Explain what an overflow error is in the context of this scenario and what could happen if the temperature exceeds the maximum value that can be stored using 8 bits.
(d) Explain how the digital representation of these temperatures is an example of abstraction.
Scoring Breakdown for FRQ
(a) (2 points) - 1 point for explaining that the analog data is measured at regular intervals (every second). - 1 point for explaining that the measured values are converted to digital using a finite number of bits.
(b) (1 point) - 1 point for stating that 256 (2^8) distinct values can be represented.
(c) (2 points) - 1 point for explaining that an overflow error occurs when the temperature exceeds the maximum value that can be represented with 8 bits. - 1 point for explaining that this could lead to incorrect temperature readings (e.g., wrapping around to a lower value or displaying a negative number).
(d) (2 points) - 1 point for explaining that the digital representation is a simplified, discrete version of the continuous analog temperature. - 1 point for explaining that the digital representation omits some of the details of the analog signal (e.g., the values between the samples).
You've got this! Remember to stay calm, take your time, and trust in your preparation. Good luck on the exam! ๐

How are we doing?
Give us your feedback and let us know how we can improve
Question 1 of 12
What is the decimal equivalent of the binary number 101? ๐คฉ
3
4
5
6