Mod
Operator
Divides two numbers and returns only the remainder.
Syntax
number_1 Mod number_2
Parts
number_1
- A numeric expression.
number_2
- A numeric expression.
Instructions
The result is the remainder after number_1
is divided by number_2
.
For example, the expression 42 Mod 5
gives a result of 2.
The result has the same sign as number_1
.
Compared to Mod
, the result of the related operator Rem
gets the sign of its second number.
But it can be easy to select the correct operator for the given conditions.
The letter “M” is nearer to the number that gives the result its sign.
Data types
TODO
Division by zero
TODO
Examples
TODO
Program Example
#Debug.PrintLine "42 Mod 5 = " & 42 Mod 5
#Debug.PrintLine "-42 Mod 5 = " & -42 Mod 5
#Debug.PrintLine "42 Mod -5 = " & 42 Mod -5
#Debug.PrintLine "-42 Mod -5 = " & -42 Mod -5
42 Mod 5 = 2 -42 Mod 5 = -2 42 Mod -5 = 2 -42 Mod -5 = -2 |