19. Using 4GL : Expressions : How Numeric Expressions Work
 
Share this page                  
How Numeric Expressions Work
The arithmetic operators in 4GL combine numeric expressions into new numeric expressions.
Operator
Description
+
Addition
-
Subtraction
*
Multiplication
/
Division
**
Exponentiation
In addition to standard numeric usage, you can do date arithmetic. For example, the following statement computes the result value for the date field "start_date":
start_date := start_date + '2 days';
Precedence of Arithmetic Operators
Arithmetic operators have the following precedence (in descending order):
**
or /
+ or -
Precedence is handled as follows:
In the absence of parentheses:
Operators of higher precedence are done first.
For adjacent operators of equal precedence, operators are done from left to right.
If there are any operators within parentheses, these are done, beginning with the innermost parentheses, before any operators outside of parentheses.
You can use parentheses to change the default order of operators, or simply to make the order explicit; for example, assume you have the expression:
a - b + c / d * e ** f
You can use parentheses as follows to emphasize the default order:
(a-b)+((c/d)*(e**f))
Use parentheses as follows to change the order:
(a-(b+(c/d))*e)**f