Mod Operator
Language Items List
Definition:
Divides two integers and returns the remainder of the division.
Syntax:
result = Operand1 Mod operand2
Syntax Description
Operand1 Any numeric expression
Operand2 Any numeric expression
Details:
The modulo arithmetic operator, also called the remainder operator, divides operand1 by operand2 and returns the remainder of the division as result. Before performing the division, all floating-point numbers are rounded to
integers. For example:
16.5 mod 10.2 = 6
Mod(x,y) can also be written as x - int(x/y) * y as shown in the following
example:
mod(16,10) = 16 - int(16/10) * 10 = 16 - 1*10 = 16 - 10 = 6
The data type of result is an integer or a long.
See Also:
Arithmetic Operators
Comparison Operators
Operator Precedence