Integer division in AP Computer Science A

Integer division is what Java does when you divide two int values with the / operator. The result is only the integer portion of the quotient, with the fractional part discarded (not rounded), so 15 / 4 evaluates to 3, not 3.75.

Verified for the 2027 AP Computer Science A examLast updated June 2026

What is integer division?

In Java, the division operator / behaves differently depending on the types involved. When both operands are int values, the result is an int, and Java keeps only the whole-number part of the quotient. It throws away everything after the decimal point. So 15 / 4 is 3, 7 / 2 is 3, and 2 / 3 is 0. This is truncation, not rounding. 7 / 2 does not become 4.

This comes straight from the CED's rules for arithmetic expressions (EK 1.3.C.2 and EK 1.3.C.3). An arithmetic operation with two int values evaluates to an int. If at least one operand is a double, the operation evaluates to a double and you get normal decimal division, so 15.0 / 4 gives 3.75. The leftover piece that integer division throws away is exactly what the remainder operator % gives you. That's why 15 / 4 and 15 % 4 are a matched pair, the quotient (3) and the remainder (3).

Why integer division matters in AP® Computer Science A

Integer division lives in Topic 1.3 (Expressions and Assignment Statements) in Unit 1 and directly supports learning objective AP Comp Sci A 1.3.C, which asks you to develop code for arithmetic expressions and determine their results. It's one of the first places Java behaves differently from the math you learned in school, which makes it one of the exam's favorite traps. Almost every "what is printed?" question involving int math is secretly testing whether you remember to truncate. It also matters far beyond Unit 1. Any time you compute an average, split things into groups, or work through loop arithmetic later in the course, the int-vs-double rule decides whether your answer is 3.75 or just 3.

How integer division connects across the course

Remainder Operator (Unit 1)

Integer division and % are two halves of the same calculation. 15 / 4 tells you how many whole 4s fit (3), and 15 % 4 tells you what's left over (3). AP questions love printing both side by side, so always compute them as a pair.

Arithmetic Expression (Unit 1)

Integer division is the rule that makes expression-evaluation questions tricky. The type of the result depends on the operands. Two ints give an int, but one double anywhere in the operation upgrades the result to a double with real decimal division.

Operator Precedence (Unit 1)

Division evaluates before addition and subtraction, so in an expression like x + y * z - x / y, the truncation happens mid-expression. You have to apply precedence first, then truncate each int division as you go.

Modular Arithmetic (Unit 1)

Wrap-around problems (clock time, last digits, even/odd checks) combine integer division with %. Division strips off the part % keeps, so the two together let you break a number into pieces, like digits or hours and minutes.

Is integer division on the AP® Computer Science A exam?

Integer division shows up constantly in "what is printed as a result of executing this code segment?" multiple-choice questions. A classic setup is int x = 15; int y = 4; followed by printing x / y and x % y, where the answer is 3 3 and every wrong choice is built from forgetting to truncate or mixing up / and %. Harder versions bury int division inside longer expressions with precedence and parentheses, like x + y * z - x / y. On FRQs, integer division is a silent point-loser. The 2019 StepTracker FRQ asked for an average of steps per day, and dividing one int total by another int count truncates the answer unless you make the calculation produce a double. When an FRQ asks for an average or any decimal result, check your types before you write the return statement.

Integer division vs remainder operator (%)

Both come from the same long-division process, but they answer different questions. Integer division (/) gives the quotient, how many times the divisor fits. The remainder operator (%) gives what's left over after that. For 15 and 4, division gives 3 and remainder gives 3, which is a coincidence here. Try 17 and 4 instead, where 17 / 4 is 4 and 17 % 4 is 1. If you ever read x % y as "x divided by y," you'll pick the wrong MCQ answer.

Key things to remember about integer division

  • Dividing two int values in Java keeps only the integer portion of the quotient, so 15 / 4 is 3 and 7 / 2 is 3.

  • Integer division truncates instead of rounding, which means 7 / 2 is 3, never 4.

  • If at least one operand is a double, the result is a double with normal decimal division, so 15.0 / 4 is 3.75.

  • Integer division and the remainder operator are a pair, with / giving the quotient and % giving the leftover.

  • Dividing a smaller int by a larger int gives 0, so 2 / 3 evaluates to 0, not 0.67.

  • On FRQs that compute averages, dividing an int total by an int count silently truncates the answer unless you make at least one value a double.

Frequently asked questions about integer division

What is integer division in Java?

Integer division happens when you use the / operator on two int values. Java keeps only the whole-number part of the quotient and discards the fraction, so 15 / 4 evaluates to 3 instead of 3.75.

Does integer division round in Java?

No. Integer division truncates, meaning it chops off the decimal part entirely. 7 / 2 is 3, not 4, and 9 / 5 is 1, not 2. Rounding never happens automatically with /.

How is integer division different from the modulo operator (%)?

The / operator gives the quotient (how many times the divisor fits) while % gives the remainder (what's left over). For 17 and 4, 17 / 4 is 4 and 17 % 4 is 1. Together they describe one long-division calculation.

What does 2 / 3 equal in Java?

It equals 0. Since both 2 and 3 are int values, Java truncates the real answer (0.666...) down to its integer portion, which is 0. This trips up a lot of AP CSA MCQs.

How do I avoid integer division when calculating an average on an FRQ?

Make at least one value in the division a double, for example by dividing by a double count or casting with (double). The CED rule is that an operation with at least one double evaluates to a double. The 2019 StepTracker FRQ tested exactly this when computing average steps per day.