fcmpl 0x95

Compares two floats and pushes -1, 0 or 1; NaN gives -1.

Opcode
0x95 (149)
Family
Comparisons
Operands
none
Length
1 byte
Operand stack
…, value1 (float), value2 (float) → …, result (int)
Can throw
nothing at run time (beyond linking errors)
Spec name
fcmp<op>

What it does

Compares two floats: pushes 1 if the first is greater, 0 if equal, -1 if less. If either is NaN, it pushes -1; that is the only difference between fcmpl and fcmpg.

javac picks whichever makes a comparison with NaN false. For a < b or a <= b it uses fcmpg: NaN gives 1, the branch past the then-part is taken, and the condition is false. For a > b and a >= b it uses fcmpl, where NaN gives -1.

How often javac uses it

In JDK 25.0.5's java.base module, fcmpl appears 65 times in 16 of its 7,391 classes: <0.01% of all instructions, the 162nd most common of 194 opcodes in use. Some of the methods that use it: java.lang.classfile.CodeBuilder.loadConstant, java.lang.Float.toHexString, java.lang.Math.max, java.lang.runtime.ExactConversionsSupport.isFloatToByteExact.

Related instructions

fcmpg Compares two floats and pushes -1, 0 or 1; NaN gives 1.lcmp Compares two longs and pushes -1, 0 or 1.dcmpl Compares two doubles and pushes -1, 0 or 1; NaN gives -1.

Specification: JVMS §6.5, fcmp<op> (Java SE 25).