%REM Function
%REM built-in function returns the remainder that results from dividing operands n by m .
*<result>* = %REM (n,m)
Parameters
n,m
Optional. Must be numeric values with zero decimal positions.
Returns
** *
Remarks
% REM and %DIV have the following relationship:
%REM(A,B) = A - (%DIV(A,B) * B)
The result in this case has the same sign as the dividend. If the operands are constants that can fit in 8-byte integer or unsigned fields, constant folding is applied to the built-in function. In this case, the % REM built-in function can be coded in the definition specifications.
Example
BEGSR Rem_Ex
DclFld Name(A) Type(*ZONED) Len(5,0)
DclFld Name(B) Type(*ZONED) Len(5,0)
DclFld Name(Result) Type(*ZONED) Len(5,0)
A = 123
B = 27
Result = %DIV (A,B)
MsgBox Result
Result = %Rem(A,B)
MsgBox Result
Result = %Rem (A,B) + %Div (A,B)
MsgBox Result
// Now, "Result" = 4, 15, and 19