Divides the value of a variable by the value of an expression, then changes the variable to the remainder.
variable Mod= expression
- A numeric variable or property.
- A numeric expression.
The two statements that follow operate the same.
variable Mod= expression variable = variable Mod expression
The element on the left side of
Mod= can be a scalar variable, a property, or an element of an array.
If it is a property, it cannot have the modifier
Mod= divides the variable or property on its left side by the value on its right side to get a quotient and a remainder.
Then it changes the variable or property on its left side to the remainder.
Mod does some of the same operations as
Thus, the sign of the variable or property (positive or negative) does not change.
This is also where
Mod= is different from
Rem= takes its sign from the expression.
Division by zero
x = 42 x Mod= 10 y = 24 y Mod= -10