Function Reference


Mod

Performs the modulus operation.

Mod ( value1, value2 )

Parameters

value1 The dividend.
value2 The divisor.

Return Value

Success: Returns the remainder when value1 is divided by value2.
Failure: Returns -1.#IND if the divisor is zero.

Remarks

This function guarantes that dividend = (dividend / divisor) * divisor + Mod(dividend, divisor).

This function does not guarantee that dividend or divisor can be represented accurately, specifically with floating point numbers.

If integers are passed this function does an integral modulo operation. Otherwise it falls back to a floating point operation which per the previous remark means it may not produce the expected output.

Related

Int

Example


Local $n = 18
If Mod($n, 2) = 0 Then
    MsgBox(0, "", $n & " is an even number.")
Else
    MsgBox(0, "", $n & " is an odd number.")
EndIf

Local $x = Mod(4, 7) ;$x == 4 because the divisor > dividend

Local $y = Mod(1, 3 / 4) ;$y == 0.25 because the divisor is a float