Arithmetic is limited in ACL to addition and subtraction. In most cases this is enough as you do not want to solve mathematical problems with ACL. But in some cases it might be helpful to multiply or divide two numbers.
How to multiply or divide two numbers with ACL?
With ACL-Verbs one can add and subtract but not perform other calculations like Multiplication and Division. Performing mathematical functions is not the focus of ACL. But with two small subroutines called MULTIPLY and DIVIDE one can multiply and divide two numbers if necessary.
Both ACL's can be found in the provided ACLLIB created during installation of TPX.
Multiplication works as follows:
ACLPGM MULTIPLY
Example of the necessary ACL-code:---------------------------------------------------------- VDEFINE MULTPLER,8 * DEFINE 1ST FACTOR VDEFINE MULTPLCN,8 * DEFINE 2ND FACTOR VDEFINE SUM,8 * RESULT * SET MULTPLER,value * SET 1ST FACTOR SET MULTPLCN,value * SET 2ND FACTOR* CALL ACLPGM MULTIPLY * INVOKE MULTIPLICATION----------------------------------------------------------The result of the multiplication is available in variable SUM.
Division works as follows:
ACLPGM DIVIDE
Example of the necessary ACL-code:---------------------------------------------------------- VDEFINE DIVIDEND,8 * DEFINE DIVIDEND VDEFINE DIVISOR,8 * DEFINE DIVISOR VDEFINE QUOTIENT,8 * DEFINE QUOTIENT VDEFINE REMAINDR,8 * DEFINE REMAINDR * SET DIVIDEND,value * SET DIVIDEND SET DIVISOR,value * SET DIVISOR * CALL ACLPGM DIVIDE * INVOKE DIVISION----------------------------------------------------------The result of the division is available in variables QUOTIENT and REMAINDR.