In AP Computer Science A, a round-off error occurs when an expression evaluates to a double more precise than the memory allotted for the type can store, so the result is rounded to the nearest representable value (EK 1.5.C.1). It's why 0.1 * 3 does not equal 0.3 in Java.
A round-off error is what happens when Java can't store a decimal value exactly. Every data type gets a fixed amount of memory, and a double only has so many bits to work with. If an expression evaluates to a value more precise than those bits can hold, Java rounds it to the nearest value it can represent. The number you get back is extremely close to the right answer, but not exactly the right answer.
The classic example shows up constantly in practice questions: 0.1 * 3 does not equal 0.3 in Java. Both values get stored as approximations, and the approximations don't quite match. The CED's official advice (EK 1.5.C.1) is blunt about the fix. To avoid rounding errors that naturally occur, use int values instead. That's why money calculations in well-written Java code use cents as an int (435 cents) rather than dollars as a double (4.35). Fancier decimal types exist in Java, but they're explicitly excluded from the AP exam.
Round-off error lives in Topic 1.5 (Casting and Ranges of Variables) in Unit 1 and directly supports learning objective AP Comp Sci A 1.5.C, which asks you to describe conditions that limit the accuracy of expressions. It's one of two ways finite memory bites you in this topic. Doubles lose precision (round-off error), and ints run out of range (integer overflow). Together they make the same big point: computers don't store math, they store bits, and bits have limits. This idea quietly follows you through the whole course. Any time you compare doubles with == in a boolean expression or accumulate doubles in a loop, round-off error is lurking, and the exam loves to check whether you know it.
Keep studying AP® Computer Science A Unit 1
Integer overflow (Unit 1)
Round-off error's sibling in Topic 1.5. Both come from finite memory, but they fail differently. A double that's too precise gets rounded to something close to correct, while an int outside the Integer.MIN_VALUE to Integer.MAX_VALUE range overflows to a value that can be wildly wrong.
Cast to int (Unit 1)
Casting a double to an int truncates everything after the decimal point (EK 1.5.A.2), which is deliberate chopping, not accidental rounding. The two interact in the rounding trick (int)(x + 0.5), where you use truncation on purpose to round a non-negative double to the nearest integer.
Arithmetic expression (Unit 1)
Round-off error is born inside arithmetic expressions. Each operation on doubles can introduce a tiny imprecision, and those tiny errors stack. Adding 0.1 to a total ten times in a loop does not give you exactly 1.0, even though the math says it should.
Boolean expressions and == comparison (Unit 1)
The practical payoff. Because of round-off error, comparing doubles with == is unreliable, so correct code checks whether two doubles are close instead, like Math.abs(a - b) < 0.001. Recognizing that pattern as an 'epsilon comparison' is a common multiple-choice ask.
Round-off error is multiple-choice territory, and the questions follow a few predictable patterns. The most common stem shows two doubles that look mathematically equal, like 0.1 * 3 and 0.3, compared with ==, and asks what prints. The answer is almost always "Not Equal" because of round-off error. A second pattern accumulates a double in a loop (adding 0.1 ten times) and asks whether the total equals 1.0. It doesn't. A third pattern shows a method like Math.abs(a - b) < 0.001 and asks you to identify its purpose, which is safely comparing doubles despite round-off error. You may also see code that does money math in integer cents and be asked why, and the answer is that int arithmetic avoids the rounding errors doubles naturally produce. The skill being tested is recognizing when a computed double is an approximation, not trusting it to be exact.
Both are accuracy problems caused by finite memory, but they hit different types in different ways. Round-off error affects doubles, happens when a value is too precise to store, and produces a result very close to the true value. Integer overflow affects ints, happens when a value is too large or small for the 4-byte range, and produces a result that can be completely wrong (even flipping sign). One nudges your answer; the other breaks it.
A round-off error happens when a double is more precise than its allotted memory can store, so Java rounds it to the nearest representable value (EK 1.5.C.1).
Because of round-off error, expressions like 0.1 * 3 == 0.3 evaluate to false in Java even though the math says they're equal.
Never compare doubles with ==; instead check whether their difference is tiny, like Math.abs(a - b) < 0.001.
The CED's recommended fix is to use int values when exactness matters, which is why money is often calculated in cents as an int.
Round-off error rounds doubles to something close to correct, while integer overflow wraps ints to something potentially very wrong; don't mix them up.
Errors accumulate: adding 0.1 to a double ten times in a loop does not produce exactly 1.0.
It's the loss of precision that occurs when an expression evaluates to a double more exact than the type's allotted memory can store, so the result gets rounded to the nearest representable value. It's covered in Topic 1.5 under learning objective AP Comp Sci A 1.5.C.
Doubles are stored as binary approximations, and 0.1 can't be represented exactly in binary. The tiny errors in 0.1 * 3 and 0.3 don't match, so comparing them with == prints "Not Equal." This exact setup is a classic AP CSA multiple-choice question.
No. Round-off error is unintentional rounding caused by limited double precision, while casting a double to an int deliberately truncates (chops off) everything after the decimal point per EK 1.5.A.2. Truncation always rounds toward zero; round-off error rounds to the nearest representable value.
Two ways: use int values when you need exact answers (like tracking money in cents), and compare doubles with a tolerance such as Math.abs(a - b) < 0.001 instead of ==. The CED explicitly says other special decimal data types are out of scope.
No. Round-off error affects doubles and produces a value very close to correct, while integer overflow happens when an int expression exceeds the range Integer.MIN_VALUE to Integer.MAX_VALUE and produces a value that's in range but not necessarily correct. They're tested side by side in Topic 1.5.
Connect this key term to the AP exam workflow: review the course, practice questions, and check related study tools.
Review units, study guides, and course resources.
Check this vocabulary in multiple-choice context.
Apply key concepts in written AP responses.
Estimate the exam score you are working toward.
Review the highest-yield facts before practice.
Put the full course together before test day.