mod
mod ( number1 : integer, number2 : integer) : number
Parameter | Type | Description | |
---|---|---|---|
number1 | integer | -> | Number to divide |
number2 | integer | -> | Number to divide by |
Result | number | <- | Returns the remainder |
Description
The mod
command returns the remainder of the integer division of number1 by number2.
Notes:
mod
accepts integer and number expressions. However, if number1 or number2 are real numbers, the numbers are first rounded and thenmod
is calculated.Be careful when using
mod
with real numbers of a large size (above 2^31) since, in this case, its operation may reach the limits of the calculation capacities of standard processors.
You can also use the % operator to calculate the remainder.
The % operator returns valid results with integer expressions. To calculate the modulo of real values, you must use the mod
command.
Example
The following example illustrates how the mod
function works with different arguments. Each line assigns a number to the vlResult variable. The comments describe the results:
var vlResult : number
vlResult = mod(3,2) // vlResult gets 1
vlResult = mod(4,2) // vlResult gets 0
vlResult = mod(3.5,2) // vlResult gets 0