11.13.7 Mod Operator
The Mod (modulo) operator computes the remainder of the division between two operands. The Mod operator is defined for the following types:
- Byte, Short, Integer and Long. The result of
x Mod yis the value produced by
x – (x \ y) * y. If
yis zero, a System.DivideByZeroException exception is thrown. The modulo operator never causes an overflow.
- Single and Double. The remainder 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.
ModuloOperatorExpression ::= Expression Mod Expression
11.13.3 Addition Operator | 11.13.4 Subtraction Operator | 11.13.5 Multiplication Operator | 11.13.6 Division Operators | 11.13.8 Exponentiation Operator | 11.13 Arithmetic Operators | Mod Operator (Visual Basic Language Reference) | Arithmetic Operators (Visual Basic Language Concepts)