2. Language Elements : Expressions : Operators : Arithmetic Operators
 
Share this page                  
Arithmetic Operators
The arithmetic operators in OpenROAD combine numeric expressions into new expressions. These operators are listed in the following table:
Operator
Description
+
Addition
-
Subtraction
*
Multiplication
/
Division
**
Exponentiation
The following are examples:
num_days = num_days + 30;
area = pi * r**2;
In addition to standard arithmetic, OpenROAD supports date arithmetic. For example, if start_date is a date field, OpenROAD can compute the result value for the following statement:
start_date = start_date + '2 days';
The precedence of operators in expressions is as follows (highest to lowest):
**
/
*
+, -
Operators are processed from left to right to control equal precedence.
For example, the following expression has a value of 14 because the multiplication operator (*) has precedence over the addition operator (+):
2 + 3 * 4
You can use parentheses to force alternate precedence. For example, placing parentheses around the expression from the previous example alters its value to 20:
(2 + 3) * 4
Take care when dividing either a float variable into an integer literal constant or an integer literal constant into a float variable, as the result is of the float type but rounded down to the nearest integer.