MULT
Script Function: It performs a multiplication.
Syntax
MULT (Operand1, Operand2)
Syntax |
Description/Format |
---|---|
Operand1 |
The first expression. |
Operand2 |
The second expression. |
Return code |
---|
The result of the multiplication |
Comments
This script function multiplies Operand1 with Operand2.
Operand1 and Operand2 must be expressions which correspond to numbers within the allowed value range of the data types. The result must not exceed this range.
You can assign the result to a script variable but it must show the corresponding data type. Any attempt to store a negative number to a variable of the data type "unsigned" results in an error. If the result is a floating-point number and the target variable is of data type "signed" or "unsigned", the decimal positions are truncated. The data type "float" supports negative numbers and floating-point numbers. The data type "string" can also be used. In this case, the result is stored as a string instead of a number. The data type of script variables can be defined by using the script element DEFINE .
The result's data type is decisive and not the operand's data type. For example, two negative operands result in a positive number which can then be stored in a target variable of the data type "unsigned".
Note that arithmetic operations using floating-point numbers can supply inexact results.
The result is returned in the 16-digit default format. Floating-point numbers also include 16 decimal places and an algebraic sign (+ or -) is used as the first sign if negative numbers are supported. Formatting can be changed by using the script function FORMAT.
Examples
The first example passes the multiplication result on to a script variable. The result that is returned is "100".
:SET &OP1# = 4
:SET &OP2# = 25
:SET &RESULT# = MULT(&OP1#,&OP2#)
The following example shows a multiplication with floating-point numbers.
:DEFINE &RESULT#,float
:SET &RESULT# = MULT(-10.31,5.45)
:P &RESULT#
The following result is output in the activation protocol:
U0020408 -0000000000000056.1895000000000000
Another Way to Perform Multiplication
Another way to perform multiplication is shown below. In this example, the value of a script variable is set to the result of 7 times 8.
:SET &MULTIPLY# = 7 * 8
:P &MULTIPLY#
The following result is output in the activation protocol:
U0020408 0000000000000056
See also:
Script element | Description |
---|---|
Performs an addition. | |
SUB | Performs a subtraction. |
MOD | Returns the remainder of a division. |
DIV | Performs a division. |
RANDOM | Generates random numbers. |
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Ordered by function