frem 0x72

Takes the remainder of two floats on top of the stack; pushes the result.

Opcode
0x72 (114)
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.

The remainder truncates toward zero, like C's fmod, not IEEE 754's remainder (which Math.IEEEremainder computes). javac emits it for % on floats, which is rare in practice: java.base contains none.

How often javac uses it

It does not appear anywhere in JDK 25.0.5's java.base module: none of its 7,391 classes uses it.

Example

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

static float floats(float a, float b) in Tour, compiled by javac 25
… 7 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
18fadd
… 4 instructions after

Open in the viewer

Related instructions

irem Takes the remainder of two ints on top of the stack; pushes the result.lrem Takes the remainder of two longs on top of the stack; pushes the result.drem Takes the remainder of two doubles on top of the stack; pushes the result.

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