lneg 0x75
Negates the long on top of the stack.
- Opcode
0x75(117)- Family
- Arithmetic and bitwise
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value (long) → …, result (long)- Can throw
- nothing at run time (beyond linking errors)
What it does
Negates the long on top of the stack: -x in Java. Negating the minimum value gives the minimum value back, because the result wraps around.
How often javac uses it
In JDK 25.0.5's java.base module, lneg appears 157 times in 50 of its 7,391 classes: <0.01% of all instructions, the 150th most common of 194 opcodes in use. Some of the methods that use it: java.lang.Long.toString, java.lang.Math.round, java.math.BigDecimal.<init>, java.math.BigInteger.valueOf.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; lneg is highlighted.
static long longs(long a, long b) in Tour, compiled by javac 25static long mix(long a, int b, short c, byte d, double e, float f, char g, boolean h) in Numbers, compiled by javac 25Related instructions
ineg Negates the int on top of the stack.fneg Negates the float on top of the stack.dneg Negates the double on top of the stack.
Specification: JVMS §6.5, lneg (Java SE 25).