Arithmetic Functions
Arithmetic Functions
Arithmetic functions are intended to provide you a way to do some basic calculation on generated values and parameters.
For example, if you have a field GEN-000 that generates a number and you what that a second field GEN-001 contains the double of the value of GEN-00 then you can use the expression "MULT(2,FIELD(GEN-000))" to generate the values of GEN-000.
Another usage could be to accumulate the successive values of the field GEN-000 into a parameter, say TOTAL. For example, if the GEN-000 generate the prices of each item for a shoping cart, the parameter TOTAL will contains the total amount of the cart. To do so, you can use the expression "SET(TOTAL,SUM(GET(TOTAL,0),FIELD(GEN-000)))".
The Functions
SUM(n1,n2,...) or ADD(n1,n2,...): sum of a sequence of numbers
This function takes a variable number of numerical parameters (at least one) and computes the sum of these parameters (n1 + n2 + ...)
Example: SUM(1,2.3,RANGE(1,10),SUM(2,WORD(2,0123456789))) evaluates into 1 + 2.3 + random number between 1 and 10 + ( 2 + a two-digit random number)
MULT(n1,n2,...): products of a sequence of numbers
This function computes the product of its operands : n1 x n2 ...
DIV(n1,n2): division
This function divides number n1 by n2. Note that n2 must be non-nul
Examples:
- DIV(1,2) returns "0.5"
- DIV(4,2) returns "2"
- DIV(a,2) returns "0" ("a" is evaluated to 0)
- DIC(2,0) raises an error, generation stops.
MOD(n1,n2) : remainder
This function returns the remainder of the integer division of n1 by n2. Note that n2 must be non-null.
Example:
- MOD(5,2) returns "1" (5 = 2*2 + 1).
FLOOR(n) : nearest smaller integer
This function returns the integer immediatly below n (or equal to n).
Example:
- FLOOR(1.9) returns "1"
- FLOOR(1) returns "1"
CEIL(n) : nearest bigger integer
This function returns the integer immediatly above n (or equal to n).
Example:
- CEIL(1.9) returns "2"
- CEIL(2) returns "2"
PRECISION(val,n) : Trunc the decimal part
This function returns float number whose decimal part is made of n digits. If the source value doesn't have enought digits, zeroes are used to complete up to n digits.
Examples:
- PRECISION(2,2) returns "2.00"
- PRECISION(3.3454,3) returns "3.345".



