fconst_1 0x0c

Pushes the float constant 1.

Opcode
0x0c (12)
Family
Constants
Operands
none
Length
1 byte
Operand stack
… → …, 1 (float)
Can throw
nothing at run time (beyond linking errors)
Spec name
fconst_<f>

What it does

Pushes the float 1.0f. Only 0, 1 and 2 have one-byte instructions; any other float constant needs ldc of a Float constant.

How often javac uses it

In JDK 25.0.5's java.base module, fconst_1 appears 41 times in 25 of its 7,391 classes: <0.01% of all instructions, the 171st most common of 194 opcodes in use. Some of the methods that use it: java.lang.classfile.CodeBuilder.loadConstant, java.lang.Float.float16ToFloat, java.lang.Math.signum, java.lang.StrictMath.copySign.

Example

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

static float floats(float a, float b) in Tour, compiled by javac 25
… 13 instructions before
26x = x / b % 7f;
14fstore_2 // x
27return -x + 0f + 1f + 2f;
15fload_2 // x
16fneg
18fadd
20fadd
22fadd

Open in the viewer

Related instructions

ldc Pushes a constant from the constant pool (index in one byte).fload Pushes the float in local variable (operand).

Specification: JVMS §6.5, fconst_<f> (Java SE 25).