# How to multiply or divide two numbers with ACL?

**Document ID :**KB000011203

**Last Modified Date :**14/02/2018

Introduction:

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.

Question:

How to multiply or divide two numbers with ACL?

Answer:

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:

- The two numbers which should be multiplicated have to be defined as Variables with names MULTPLCN (multiplicand) and MULTPLER (multiplier), for the result of the multiplication the Variable called SUM needs also to be defined. All Variables need to be of Type VDEFINE or GDEFINE. If other names are desired, their names have to be changed in the ACL MULTIPLY as well.
- The subroutine is called by statement
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:

- The two numbers which should be divided have to be defined as Variables with names DIVIDEND and DIVISOR, the result of the division appears in variables QUOTIENT and REMAINDR. All Variables need to be of Type VDEFINE or GDEFINE.
- The subroutine is called by statement
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.