Understanding underlying number systems is a crucial prerequisite for computer science. While Java handles decimal numbers for you natively, understanding exactly how data is represented in memory—specifically Binary (Base-2) and Hexadecimal (Base-16)—is essential for grasping integer limits, bitwise operations, and memory bounds.
In this interactive module, you will practice rapid conversions, identify overflow boundaries, and translate machine-level data logic. These 12 questions will solidify the numerical foundations you need for complex AP CSA algorithms.
Crash Course: Expand the sections below for a quick step-by-step refresher before starting the quiz.
1. Binary (Base-2) Rules & Tricks
Each position in a binary number represents a power of 2. Read from right to left, starting at 20 (which is 1) and double the value for each step left.
Example: Convert 10110 to Decimal
- 16s place: 1 → 16
- 8s place: 0 → 0
- 4s place: 1 → 4
- 2s place: 1 → 2
- 1s place: 0 → 0
Total: 16 + 4 + 2 = 22
Quick AP Exam Tricks:
- The Even/Odd Trick: If a binary number ends in 0, it is even. If it ends in 1, it is odd.
- Max Values: The maximum decimal value for an n-bit unsigned binary number is always
(2^n) - 1.
2. Hexadecimal (Base-16) Quick Reference
Hexadecimal uses 16 symbols: numbers 0-9 and letters A-F. It is heavily used in Java to represent memory addresses and object hash codes.
| Hex Letter | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| Decimal Value | 10 | 11 | 12 | 13 | 14 | 15 |
Example: Convert 2B to Decimal
The right column is the 1s place. The left column is the 16s place.
- 2 in the 16s place → 2 * 16 = 32
- B (11) in the 1s place → 11 * 1 = 11
Total: 32 + 11 = 43
Binary, Decimal & Hexadecimal
10110?10110 has a 1 in the 16s place, the 4s place, and the 2s place. 16 + 4 + 2 = 22.
45?45 – 32 = 13.
Next is 8 (13 – 8 = 5).
Next is 4 (5 – 4 = 1).
Next is 1 (1 – 1 = 0).
Putting a ‘1’ in the 32, 8, 4, and 1 columns gives us
101101.2B?So,
2B = (2 * 16) + (11 * 1) = 32 + 11 = 43.175?175 ÷ 16 = 10 with a remainder of 15.
In Hex, 10 is ‘A’ and 15 is ‘F’. Therefore, the result is
AF.1101 and 1010?1101 is 13, and 1010 is 10. 13 + 10 = 23.
Converting 23 back to binary (16 + 4 + 2 + 1) gives us
10111.C4 represented in binary?‘C’ is 12, which is
1100.‘4’ is
0100.Combine them directly to get
11000100.10010, what is the decimal place value of the leftmost ‘1’?A) Binary 1111 = 15
B) Decimal 14 = 14
C) Hexadecimal E = 14
D) Binary 10000 = 16. Therefore, D is the largest.
101 becomes 1010) has what mathematical effect?101 is 5. 1010 is 10.int?int in Java is a 32-bit signed integer. This is why the maximum positive value for an `int` on the AP exam is roughly 2.14 billion (which is 231 – 1, using one bit for the positive/negative sign).Number Systems Practice Complete!
Why Number Systems Matter for AP CSA
On the AP exam, you rarely have to convert massive binary numbers by hand, but you must understand the constraints of Java’s primitive data types. Knowing that a standard 32-bit signed int maxes out at roughly 2.14 billion (231 – 1) helps you instantly identify potential integer overflow errors in multiple-choice code traces.
Additionally, hexadecimal frequently appears when discussing object memory references. If you ever try to print a Java object without writing a proper .toString() method, the output includes a hexadecimal hash code representing its location in memory.
Ready for the Next Step?
Now that you are comfortable with base conversions and memory representation, it is time to apply numerical logic directly to Java’s control flow.
Continue your AP CSA review by moving on to the Truth Tables & Booleans Practice, where we break down complex logical operators, short-circuit evaluation, and De Morgan’s Laws.