MULT

Use the MULT script function to multiply two values and return the result as a 16-digit alphanumeric string with leading zeros.

Syntax

MULT (Operand1, Operand2)

Parameters

  • MULT
    Multiplies Operand1by Operand2
    Return code: result of the multiplication

  • Operand1
    First expression
    Format: script literal, script variable or number specified without quotation marks

  • Operand2
    Second expression
    Format: script literal, script variable or number specified without quotation marks

Notes:

  • Ensure that the values lie within the allowed range for the declared data types of your script variables. The data type of the result is decisive, not the data type of the operand. Not all data types support negative values and decimals. Negative values result in an error if the variable is not data type float. If the data type of the variable does not allow decimals, any decimals in your result are truncated. For more information, see Script Variable Data Types.
  • Results are returned in the default 16-digit format, with leading zeros. Floating-point numbers also include 16 decimal places. If negative numbers are supported, an algebraic sign (+ or -) is used as the first character.
  • If the result is a floating-point number and the target variable is data type signed or unsigned, the decimals are rounded up or down to the nearest whole number.

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

Examples

The following example passes the multiplication result (100) to a script variable. The example uses two variables as operands:

:SET  &OP1# = 4
:
SET  &OP2# = 25
:
SET  &RESULT# = MULT(&OP1#,&OP2#)

The following example multiplies floating-point numbers and prints the result in the activation report:

:DEFINE &RESULT#,float
:SET &RESULT#MULT(-10.31,5.45)
:P &RESULT#

The result in the activation report would look like this:

U0020408 -0000000000000056.1895000000000000

The following example shows how to perform a multiplication using an arithmetic expression:

:SET &MULTIPLY# = 7 * 8
:
P &MULTIPLY#

The result in the activation report would look like this:

U0020408 0000000000000056

See also: