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

# ddiv

## Operation

Divide `double`

## Format

```
ddiv
```

## Forms

*ddiv* = 111 (0x6f)

## Operand Stack

..., *value1*, *value2* →

..., *result*

## Description

Both *value1* and *value2* must be of type `double`. The values are popped from the operand stack and undergo value set conversion ([§2.8.3](2.8.3.md)), resulting in *value1*' and *value2*'. The `double` *result* is *value1*' / *value2*'. The *result* is pushed onto the operand stack.

The result of a *ddiv* instruction is governed by the rules of IEEE 754 arithmetic:

- If either *value1*' or *value2*' is NaN, the result is NaN.
- If neither *value1*' nor *value2*' is NaN, the sign of the result is positive if both values have the same sign, negative if the values have different signs.
- Division of an infinity by an infinity results in NaN.
- Division of an infinity by a finite value results in a signed infinity, with the sign-producing rule just given.
- Division of a finite value by an infinity results in a signed zero, with the sign-producing rule just given.
- Division of a zero by a zero results in NaN; division of zero by any other finite value results in a signed zero, with the sign-producing rule just given.
- Division of a nonzero finite value by a zero results in a signed infinity, with the sign-producing rule just given.
- In the remaining cases, where neither operand is an infinity, a zero, or NaN, the quotient is computed and rounded to the nearest `double` using the round to nearest rounding policy ([§2.8](2.8.md)). If the magnitude is too large to represent as a `double`, we say the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small to represent as a `double`, we say the operation underflows; the result is then a zero of appropriate sign.

The Java Virtual Machine requires support of gradual underflow. Despite the fact that overflow, underflow, division by zero, or loss of precision may occur, execution of a *ddiv* instruction never throws a run-time exception.
