CRE Programmer's Guide

Math Functions
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
7-11
Mod
Mod
The Mod functions return the result of dividing their first parameter by their second
parameter using integer division if their parameters are integers, or using floating-point
division if their parameters are floating-point numbers.
number
is the dividend in calculating the remainder.
modulus
is the divisor in calculating the remainder.
Return Value
For an integer modulo function, the Mod functions return the result of evaluating the
following expression using integer division:
number - ((number ) * modulus)
((modulus) )
For a floating-point modulo function, the Mod functions return the result of evaluating
the following expression using floating-point division:
number - (truncate(number ) * modulus)
( (modulus) )
Considerations
If modulus = 0:
The integer modulo functions causes an arithmetic fault.
The floating-point modulo functions return 0.
INT PROC { CRE_Mod_Int16_ } (number, modulus);
{ RTL_Mod_Int16_}
INT number, modulus; ! in TNS only
INT(32) PROC { CRE_Mod_Int32_ } (number, modulus);
{ RTL_Mod_Int32_ }
INT(32) number, modulus; ! in TNS only
INT(64) PROC { CRE_Mod_Int64_ } (number, modulus);
{ RTL_Mod_Int64_ }
INT(64) number, modulus; ! in TNS only
REAL(32) PROC RTL_Mod_Real32_ (number, modulus);
REAL(32) number, modulus; ! in TNS only
REAL(64) PROC RTL_Mod_Real64_ (number, modulus);
REAL(64) number, modulus; ! in TNS only