For a division operation of the X/Y form, a types extension is applied to select a standard implementation. The type of the operation result matches the operand type (after their possible extension). The following standard implementations are determined. All of them calculate the operands quotient:
Floating-point division is determined for the types: Float and Double. The quotient is calculated according to the rules of IEEE 754. The following table contains all possible combinations of operand values and corresponding operator results. In the table, x and y are positive finite values. z is the quotient of x and y. If the result is too large for the destination type, z is infinity. If the result is too small for the destination type, z is zero.
| +y | –y | +0 | –0 | +∞ | –∞ | NaN | |
| +x | +z | -z | +∞ | –∞ | +0 | -0 | NaN |
| -x | -z | +z | –∞ | +∞ | -0 | +0 | NaN |
| +0 | +0 | -0 | NaN | NaN | +0 | -0 | NaN |
| -0 | -0 | +0 | NaN | NaN | -0 | +0 | NaN |
| +∞ | +∞ | –∞ | +∞ | –∞ | NaN | NaN | NaN |
| –∞ | –∞ | +∞ | –∞ | +∞ | NaN | NaN | NaN |
| NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
Decimal division is determined for the Decimal type. If the value of the right operand is zero, System.DivideByZeroException is raised. If the output value is too large to be represented by the Decimal type, System.OverflowException is raised. If the output value is too small to be represented by the Decimal type, the result is zero.
See also: