Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
11.13.7 Mod Operator

11.13.7 Mod Operator

Visual Studio .NET 2003

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 y is the value produced by x – (x \ y) * y. If y is 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

See Also

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)

Show:
© 2015 Microsoft