Mod=
Operator
Divides the value of a variable by the value of an expression, then changes the variable to the remainder.
Note:
Mod=
usually operates the same as Rem=
.
See the section TBD to know why and how to change its operation.
Syntax
variable Mod= expression
Parts
variable
- A numeric variable or property.
expression
- A numeric expression.
Instructions
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 @ReadOnly
.
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 Mod=
.
Thus, the sign of the variable or property (positive or negative) does not change.
This is also where Mod=
is different from Rem=
.
Rem=
takes its sign from the expression.
Data types
TODO
Division by zero
TODO
Examples
x = 42
x Mod= 10
y = 24
y Mod= -10
variable | value |
---|---|
x | 2 |
y | -4 |