JVM Knowledge

i2f

Raw .md Oracle

Operation

Convert int to float

Format

i2f

Forms

i2f = 134 (0x86)

Operand Stack

..., value →

..., result

Description

The value on the top of the operand stack must be of type int. It is popped from the operand stack and converted to the float result using IEEE 754 round to nearest mode. The result is pushed onto the operand stack.

Notes

The i2f instruction performs a widening primitive conversion (JLS §5.1.2), but may result in a loss of precision because values of type float have only 24 significand bits.