ldiv 0x6d
Divides two longs on top of the stack; pushes the result.
- Opcode
0x6d(109)- Family
- Arithmetic and bitwise
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value1 (long), value2 (long) → …, result (long)- Can throw
ArithmeticException
What it does
a / b on two longs: pops b, then a, and pushes the result.
Dividing by zero throws ArithmeticException. Dividing the minimum value by -1 overflows quietly and gives the minimum value.
How often javac uses it
In JDK 25.0.5's java.base module, ldiv appears 266 times in 69 of its 7,391 classes: 0.01% of all instructions, the 139th most common of 194 opcodes in use. Some of the methods that use it: java.lang.Integer.divideUnsigned, java.lang.Long.toString, java.lang.Math.multiplyExact, java.lang.ref.ReferenceQueue.remove0.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; ldiv is highlighted.
static long longs(long a, long b) in Tour, compiled by javac 25Related instructions
idiv Divides two ints on top of the stack; pushes the result.fdiv Divides two floats on top of the stack; pushes the result.ddiv Divides two doubles on top of the stack; pushes the result.
Specification: JVMS §6.5, ldiv (Java SE 25).