AP® Computer Science A glossary

Integer division

Also called: int division

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

Dividing two int values: the result is only the integer part of the quotient, so 7 / 2 is 3.

Appears in the course and exam description (CED): 1.3.C.3

When both values are int, Java drops the decimal part and the result moves toward zero. If at least one value is a double, the result is the full quotient.

System.out.println(7 / 2);
System.out.println(-7 / 2);
System.out.println(7 / 2.0);

Output:

3
-3
3.5
Learn it properly, with a checkpoint 1.3 Expressions and Output

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure