ITP/Server supports the following operations in expressions:
Operation |
Description |
Operands |
Result |
Remarks |
|---|---|---|---|---|
x Or y |
Logical or |
Boolean |
Boolean |
ITP/Server uses short-circuit evaluation. If x evaluates to True, y is not evaluated. |
x And y |
Logical and |
Boolean |
Boolean |
ITP/Server uses short-circuit evaluation. If x evaluates to False, y is not evaluated. |
x = y |
Equal |
|
Boolean |
Comparisons on Strings are done case sensitive.
|
x <> y |
Not equal |
|
Boolean |
|
x <= y |
Less or equal |
|
Boolean |
|
x < y |
Less |
|
Boolean |
|
x >= y |
Greater or equal |
|
Boolean |
|
x > y |
Greater |
|
Boolean |
|
x + y |
Add |
Number |
Number |
The function of the '+' operator depends on its operands. |
x + y |
Concatenate |
String |
String |
|
x – y |
Subtract |
Number |
Number |
|
x * y |
Multiply |
Number |
Number |
|
x / y |
Divide |
Number |
Number |
|
x % y |
Modulo |
Number |
Number |
|
Not x |
Negation |
Boolean |
Boolean |
|
-x |
Negation |
Number |
Number |
|
Priorities
When multiple operators occur in an expression, the expression is evaluated in a specific order depending upon the operators in the expression. Parentheses signs '(' and ')' can be used to change the order of expression evaluation.
The following table shows the priority of the operators used in expressions:
Priority |
Operators |
|---|---|
1 |
- (Negation), Not (Negation) |
2 |
* (Multiply), / (Divide), % (Modulo) |
3 |
+ (Add), + (Concatenate), – (Subtract) |
4 |
<= (Less or equal), < (Less), >= (Greater or equal), > (Greater) |
5 |
= (Equal), <> (Not equal) |
6 |
And (logical and) |
7 |
Or (logical or) |
A priority of 1 is the highest priority (signed values are evaluated first); a priority of 7 is the lowest priority (Or operations are evaluated last). When operators with different priority levels appear in an expression, operations are performed according to priorities.
When operators of the same priority appear in an expression, operations are performed from left to right within the expression. Parentheses can always be used to control the order in which operations are performed. The value of a parenthetical expression is determined from the innermost level to the outermost level, following the priority rules within matching sets of parentheses.
Examples
1 + 1 # results in 2.
"1" + "1"ᾉ# results in "11": two text values concatenated.
(10+15)/5 # results in 5: 10+15=25, 25/5=5.
10+15/5 # results in 13: 15/5=3, 10+3=13.