Mod

From AutoIt Wiki

Jump to: navigation, search

Performs the modulus operation. Adapted from AutoIt docs.

Contents

Syntax

$x = Mod(value1,value2)

Parameters

value1The dividend.
value2The divisor.

Return Value

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

Example

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

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

$y = mod(1, 3/4)  ;$y == 0.25 because the divisor is a float
Personal tools