fdiv 0x6e

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

Opcode
0x6e (110)
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.

Floating-point division by zero does not throw: it gives Infinity, -Infinity or NaN.

How often javac uses it

In JDK 25.0.5's java.base module, fdiv appears 10 times in 8 of its 7,391 classes: <0.01% of all instructions, the 187th most common of 194 opcodes in use. Some of the methods that use it: java.math.BigDecimal.floatValue, java.util.concurrent.ConcurrentHashMap.<init>, java.util.HashSet.readObject, java.util.Hashtable.readHashtable.

Example

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

static float floats(float a, float b) in Tour, compiled by javac 25
… 5 instructions before
25float x = a + b - a * b;
7fstore_2 // x
26x = x / b % 7f;
8fload_2 // x
9fload_1 // b
10fdiv
11ldc #13// 7
13frem
14fstore_2 // x
27return -x + 0f + 1f + 2f;
15fload_2 // x
16fneg
… 6 instructions after

Open in the viewer

Related instructions

idiv Divides two ints on top of the stack; pushes the result.ldiv Divides two longs on top of the stack; pushes the result.ddiv Divides two doubles on top of the stack; pushes the result.

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