DIV

Use the DIV script function to divide one value by another and return the result as a 16-digit alphanumeric string with leading zeros.

Syntax

DIV (Operand1, Operand2)

Parameters

Notes:

Tip: You can remove leading zeros and otherwise edit the format of results with the FORMAT script function.

Examples

The following example passes the division result (5) to a script variable. The examples uses variables for both operands.

:SET &OP1# = '100'
:
SET &OP2# = '20'
:
SET &RESULT# = DIV(&OP1#,&OP2#)

If the data type of the target variable is not float, decimal places are rounded up or down to the nearest whole number. In the following example, the value stored in the result variable is rounded down to 0:

:DEFINE &RESULT#, unsigned
:
SET &RESULT# = DIV(10,30)

The following script divides floating-point numbers, and prints the result in the activation report:

:DEFINE &RESULT#,float
:SET &RESULT#DIV(-9,-2.25)
:P &RESULT#

The result in the activation report would look like this:

U0020408 +0000000000000004.0000000000000000

The following example performs a division using an arithmetic expression:

:SET &DIVIDE# = 10 / 2
:
P &DIVIDE#

The result in the activation report would look like this:

U0020408 0000000000000005

See also:

seealso

Arithmetic Calculations in Scripts