Divide int
Bytecode
Type | Description |
u1 | idiv opcode = 0x6C (108) |
Stack ..., value1, value2 => ..., result
Description
Pops the top two integers from the operand stack and divides the second-from top integer (value2) by the top integer (value1), i.e. computes (value2 div value1). The quotient result is truncated to the nearest integer (with rounding going towards zero, so 1.7 becomes 1) and placed on the stack.
Both value1 and value2 must be of type int
. The values are
popped from the operand stack. The int
result is the value of the Java
expression value1 / value2. The result is pushed onto the operand
stack.
Exceptions
ArithmeticException - attempt to divide by 0 (i.e. value1 is 0)
Notes
Because of the two's-complement representation used for negative numbers, dividing Integer.MIN_VALUE by -1 produces Integer.MIN_VALUE, not Integer.MAX_VALUE as you might expect.