The division operator computes the quotient of two operands. There are two division operators: the regular division operator and the integer division operator.
Byte
, Short
, Integer
and Long
. If the value of the right operand is zero, a System.DivideByZeroException
exception is thrown. The division rounds the result towards zero, and the absolute value of the result is the largest possible integer that is less than the absolute value of the quotient of the two operands. The result is zero or positive when the two operands have the same sign and zero or negative when the two operands have opposite signs. If the left operand is the maximum negative Short
, Integer
or Long
and the right operand is –1
, an overflow occurs. If integer overflow checking in on, this causes a System.OverflowException
exception to be thrown. Otherwise, the overflow is not reported and the result is instead the value of the left operand.The regular division operator is defined for:
Single
and Double
. The quotient is computed according to the rules of IEEE 754 arithmetic.Decimal
. If the value of the right operand is zero, a System.DivideByZeroException
exception is thrown. If the resulting value is too large to represent in the decimal format, a System.OverflowException
exception is thrown. If the result value is too small to represent in the decimal format, the result is zero.According to normal numeric promotion rules, regular division purely between operands of types Byte
, Short
, Integer
and Long
would be illegal. However, in this specific situation, those types are treated specially and both operands are promoted to Double
. The promotion happens to Double
instead of Decimal
because Double
division is more performant than Decimal
division on the NGWS Frameworks and Runtime.
/
Expression\
Expression