How to multiply or divide two numbers with ACL?

### How to multiply or divide two numbers with ACL?

book

calendar_today

#### Products

Teleview TELEVIEW- PACKAGE TPX - Session Management Vman Session Management for z/OS

#### Issue/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.

How to multiply or divide two numbers with ACL?

#### Environment

Release: NVINAM00200-5.2-TPX-Session Management-Access Management package
Component:

#### Resolution

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:

1. 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.
2. 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:

1. 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.
2. The subroutine is called by statement
`      ACLPGM    DIVIDEExample 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.`