---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 26 Edition"
java_version: 26
chapter: "Chapter 6. The Java Virtual Machine Instruction Set"
section: "6.5.f2i"
heading: "f2i"
parent: "6.5. Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se26/html/jvms-6.html#jvms-6.5.f2i
id: "6.5.f2i"
url: https://jvm.obfuscated.software/jvms/se26/6.5.f2i.html
raw: https://jvm.obfuscated.software/jvms/se26/6.5.f2i.md
---

# f2i

## Operation

Convert `float` to `int`

## Format

```
f2i
```

## Forms

*f2i* = 139 (0x8b)

## Operand Stack

..., *value* →

..., *result*

## Description

The *value* on the top of the operand stack must be of type `float`. It is popped from the operand stack and converted to an `int` *result*. The *result* is pushed onto the operand stack:

- If the *value* is NaN, the *result* of the conversion is an `int` 0.
- Otherwise, if the *value* is not an infinity, it is rounded to an integer value V using the round toward zero rounding policy ([§2.8](2.8.md)). If this integer value V can be represented as an `int`, then the *result* is the `int` value V.
- Otherwise, either the *value* must be too small (a negative value of large magnitude or negative infinity), and the *result* is the smallest representable value of type `int`, or the *value* must be too large (a positive value of large magnitude or positive infinity), and the *result* is the largest representable value of type `int`.

## Notes

The *f2i* instruction performs a narrowing primitive conversion (JLS §5.1.3). It may lose information about the overall magnitude of *value* and may also lose precision.
