MODULO
The MODULO instruction (which may be abbreviated as MOD) divides the absolute value of the first operand into the absolute value of the second operand and returns the remainder value. Optionally, the remainder result can be stored into a third operand. The instruction uses one of the following formats:
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A Numeric Variable, numeric Literal, or Expression that is the divisor for the Modulo calculation.
sep
Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.
dest
Required. A Numeric Variable that is the dividend for the calculation. The final calculated remainder value is returned in this variable.
source1
Required. A Numeric Variable, numeric Literal, or Expression that is the divisor for the calculation.
sep2
Required. A comma or the keyword GIVING.
source2
Required. A Numeric Variable that is the dividend for the calculation.
dest1
Required. A Numeric Variable that returns the final calculated Modulo remainder value.
Flags Affected: LESS, OVER, ZERO
Note the following:
The final result is placed in the {dest} or {dest1} variable depending on the syntax format being used. The other operands always remain unchanged.
Only the absolute value of any input variable is used for the for the Modulo calculation. There are no negative values used in the Modulo calculation.
If any input variable has a fractional component, the fractional component is truncated. There are no rounded values used for the Modulo calculation.
If the divisor value is zero, a runtime F01 error is generated.
The EQUAL (or ZERO), OVER, and LESS Condition Flags are applicable.
Example:
See Also: CALC, MOVE, Mathematical Instructions
![]() |