Format | Assembly Format | Description |
---|---|---|
5B | div |
Divide two values to return a quotient or floating-point result. |
…, value1, value2 → …, result
result = value1 div
value2 satisfies the following conditions:
-
|result| = |value1| / |value2|, and
-
sign(result) = +, if sign(value1) = sign(value2), or
–, if sign(value1) ~= sign(value2)
The div
instruction computes result and pushes it on the stack. Integer division truncates towards zero.
Floating-point division is per IEC 60559:1989. In particular, division of a finite number by 0 produces the correctly signed infinite value and
-
0 / 0 = NaN
-
infinity / infinity = NaN
-
X / infinity = 0
The acceptable operand types and their corresponding result data type are encapsulated in Table 2: Binary Numeric Operations.
Integral operations throw System.ArithmeticException
if the result cannot be represented in the result type. (This can happen if value1 is the smallest representable integer value, and value2 is -1.)
Integral operations throw DivideByZeroException
if value2 is zero.
Floating-point operations never throw an exception (they produce NaNs or infinities instead, see Partition I).
+14 div +3 is 4 |
+14 div -3 is -4 |
-14 div +3 is -4 |
-14 div -3 is 4 |