Core Function Mod
From Sputnik Wiki
Mod( <expression>, <expression2> )
Contents |
Description
Performs the modulus operation.
Parameters
expression
The dividend.
expression2
The divisor.
Return Value
quotient = dividend / divisor.
Remarks
Some might wonder the point of such a function when clear % operators exist but why not!.
Example
$n = 18; If ( Mod($n, 2) == 0 ) { println("$n is an even number."); } Else { println("$n is an odd number."); } $x = Mod(4, 7); println($x); // $x == 4 because the divisor > dividend $y = Mod(1, 3.0/4.0); // We had to place .0 onto the end just so it forces it to be a double println($y); // $y == 0.25 because the divisor is a float
Of course we could just use the % modulus operator
$n = 18; If ( $n % 2 == 0 ) { println("$n is an even number."); } Else { println("$n is an odd number."); } $x = 4 % 7; println($x); // $x == 4 because the divisor > dividend $y = 1 % 3.0/4.0; // We had to place .0 onto the end just so it forces it to be a double println($y); // $y == 0.25 because the divisor is a float