fadd 0x62

Adds two floats on top of the stack; pushes the result.

Opcode
0x62 (98)
Family
Arithmetic and bitwise
Operands
none
Length
1 byte
Operand stack
…, value1 (float), value2 (float) → …, result (float)
Can throw
nothing at run time (beyond linking errors)

What it does

a + b on two floats: pops b, then a, and pushes the result.

How often javac uses it

In JDK 25.0.5's java.base module, fadd appears 10 times in 4 of its 7,391 classes: <0.01% of all instructions, the 185th most common of 194 opcodes in use. Some of the methods that use it: java.lang.Float.sum, java.lang.Math.fma, jdk.internal.misc.Unsafe.getAndAddFloat, jdk.internal.util.random.RandomSupport.boundedNextFloat.

Example

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; fadd is highlighted.

static float floats(float a, float b) in Tour, compiled by javac 25
25float x = a + b - a * b;
0fload_0 // a
1fload_1 // b
3fload_0 // a
4fload_1 // b
7fstore_2 // x
26x = x / b % 7f;
8fload_2 // x
… 14 instructions after

Open in the viewer

Related instructions

iadd Adds two ints on top of the stack; pushes the result.ladd Adds two longs on top of the stack; pushes the result.dadd Adds two doubles on top of the stack; pushes the result.

Specification: JVMS §6.5, fadd (Java SE 25).