Add two integers
Bytecode
Type | Description |
u1 | iadd opcode = 0x60 (96) |
Stack ..., value1, value2 => ..., result
Pops two integers from the operand stack, adds them, and pushes the integer result back onto the stack. On overflow, iadd produces a result whose low order bits are correct, but whose sign bit may be incorrect.
Both value1 and value2 must be of type int
. The values are
popped from the operand stack. The int
result is value1 + value2.
The result is pushed onto the operand stack.
If an iadd overflows, then the result is the low-order bits of the true mathematical result in a sufficiently wide two's-complement format. If overflow occurs, then the sign of the result will not be the same as the sign of the mathematical sum of the two values.
Example
bipush 5 ; push first int bipush 4 ; push second int iadd ; add integers ; the top of the stack now ; contains the integer 9