Operador Mod

L'operador MOD recibe dos espresiones numb茅riques y devuelve'l residuu de la divisi贸n.

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:

  1. The value 16.4 is rounded to 16.

  2. The value 5.9 is rounded to 6.

  3. La operaci贸n 16 MOD 6 devuelve 4, el residuu de la divisi贸n de 16 por 6.

note

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.


Syntax:


Result谩u = Espresi贸n1 MOD Espresi贸n2

Return value:

Enteru

Parameters:

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.

Example:


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

Please support us!