Divides one number by another and returns the remainder.
This version of the MOD function is provided for compatibility with mvEnterprise. It is only available in MVENTERPRISE mode (set with the $OPTIONS statement).
MOD(expression1,expression2)
REM(expression1,expression2)
expression1, expression2
are any valid DataBasic expressions, or any strings, substrings, or values,
that evaluate to numeric values.
Returns the remainder when expression1 is divided by expression2.
expression2 cannot be zero.
The sign of the result is the same as the sign of expression1.
While MOD (or REM) is typically used with integer operands, it also works for floating point values. For example, MOD(4.3, 2.1) returns 0.1.
MOD returns a value calculated as follows:
MOD(A,B) = A - (INT(A/B) * B)
Because MOD returns zero when expression1 is exactly divisible by expression2, this function is typically used to test whether a number is a multiple of another number.
IF MOD(A,2) THEN PRINT 'ODD' ELSE PRINT 'EVEN' END
Determines if a number is odd or even and prints appropriate message.
INPUT NUM IF REM(NUM,3) THEN STOP ELSE GO 100
Tests to see if NUM is a multiple of 3. If it isn't, the program terminates; otherwise, control transfers to statement 100.