dneg 0x77
Negates the double on top of the stack.
- Opcode
0x77(119)- Family
- Arithmetic and bitwise
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value (double) → …, result (double)- Can throw
- nothing at run time (beyond linking errors)
What it does
Negates the double on top of the stack: -x in Java. For floating point it flips the sign bit, so it turns 0.0 into -0.0, which subtracting from zero would not.
How often javac uses it
In JDK 25.0.5's java.base module, dneg appears 47 times in 21 of its 7,391 classes: <0.01% of all instructions, the 168th most common of 194 opcodes in use. Some of the methods that use it: java.io.StreamTokenizer.nextToken, java.lang.FdLibm$Asin.compute, java.lang.FdLibm$Atan.compute, java.lang.FdLibm$Atan2.compute.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; dneg is highlighted.
static double doubles(double a, double b) in Tour, compiled by javac 25Related instructions
ineg Negates the int on top of the stack.lneg Negates the long on top of the stack.fneg Negates the float on top of the stack.
Specification: JVMS §6.5, dneg (Java SE 25).