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

# idiv

## Operation

Divide `int`

## Format

```
idiv
```

## Forms

*idiv* = 108 (0x6c)

## Operand Stack

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

..., *result*

## Description

Both *value1* and *value2* must be of type `int`. The values are popped from the operand stack. The `int` *result* is the value of the Java programming language expression *value1* / *value2* (JLS §15.17.2). The *result* is pushed onto the operand stack.

An `int` division rounds towards 0; that is, the quotient produced for `int` values in *n*/*d* is an `int` value *q* whose magnitude is as large as possible while satisfying |*d* ⋅ *q*| ≤ |*n*|. Moreover, *q* is positive when |*n*| ≥ |*d*| and *n* and *d* have the same sign, but *q* is negative when |*n*| ≥ |*d*| and *n* and *d* have opposite signs.

There is one special case that does not satisfy this rule: if the dividend is the negative integer of largest possible magnitude for the `int` type, and the divisor is -1, then overflow occurs, and the result is equal to the dividend. Despite the overflow, no exception is thrown in this case.

## Run-time Exception

If the value of the divisor in an `int` division is 0, *idiv* throws an `ArithmeticException`.
