MOD
Modulus (Division Remainder)
This numeric function returns the remainder from the division of the two numbers specified.
Syntax
Section titled “Syntax”MOD (numeric-dividend, numeric-divisor [,ERR=line-ref|,ERC=error-code])numeric-dividend- is any number.
numeric-divisor- is any number.
line-ref- is the program line number or label to branch to if an error is produced by this function.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”The range of MOD in any given situation is 0 through the quantity (numeric-divisor - 1) and maintains the sign (+/-) of numeric-dividend.
The entire result of a division operation is reflected by INT (numeric-dividend / numeric-divisor), which gives the integer result of the division, and MOD (numeric-dividend, numeric-divisor), which gives the remainder.
Examples
Section titled “Examples”MOD (8,3)divides 8 by 3 and returns the value 2, the remainder.
MOD (X,Y)If X = 25 and Y = 4, divides 25 by 4 and returns the value 1, the remainder.
MOD (-3,2)returns the value -1.
MOD (-3,2.5)returns the value -0.5.
MOD (-2,3)returns the value -2.
From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF