LibreOffice 7.6 Help
The MOD operator takes in two numeric expressions and returns the remainder of the division.
For example, the result of 21 MOD 6 is 3 because after dividing 21 by 6, the remainder of the division is 3.
If the MOD operation involves non-integer values, both operands are rounded to the nearest integer values. Hence, the value returned by a MOD operation will always be an integer number.
For example, the expression 16.4 MOD 5.9 is evaluated as follows:
The value 16.4 is rounded to 16.
The value 5.9 is rounded to 6.
The operation 16 MOD 6 returns 4, which is the remainder after dividing 16 by 6.
Be aware that BASIC's MOD operator and Calc's MOD Function behave differently. In Calc, both operands can be decimal values and they are not rounded before division, thus the resulting remainder may be a decimal value.
Result = Expression1 MOD Expression2
Integer
Result: Any numeric variable that contains the result of the MOD operation.
Expression1, Expression2: Any numeric expressions for which you want to calculate the remainder after the division of Expression1 by Expression2.
Sub ExampleMod
Dim a As Double, b as Double
a = 10 : b = 4
Print a Mod b 'Returns 2
a = 18 : b = 3.2
Print a Mod b 'Returns 0
a = 16.4 : b = 5.9
Print a Mod b 'Returns 4
End Sub