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

# d2f

## Operation

Convert `double` to `float`

## Format

```
d2f
```

## Forms

*d2f* = 144 (0x90)

## Operand Stack

..., *value* →

..., *result*

## Description

The *value* on the top of the operand stack must be of type `double`. It is popped from the operand stack and undergoes value set conversion ([§2.8.3](2.8.3.md)) resulting in *value*'. Then *value*' is converted to a `float` result using IEEE 754 round to nearest mode. The *result* is pushed onto the operand stack.

Where an *d2f* instruction is FP-strict ([§2.8.2](2.8.2.md)), the result of the conversion is always rounded to the nearest representable value in the float value set ([§2.3.2](2.3.2.md)).

Where an *d2f* instruction is not FP-strict, the result of the conversion may be taken from the float-extended-exponent value set ([§2.3.2](2.3.2.md)); it is not necessarily rounded to the nearest representable value in the float value set.

A finite *value*' too small to be represented as a `float` is converted to a zero of the same sign; a finite *value*' too large to be represented as a `float` is converted to an infinity of the same sign. A `double` NaN is converted to a `float` NaN.

## Notes

The *d2f* 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.
