Operators that can be used in expressions

Constants and variables may be combined by an operator to produce a result that, in turn, may be used with another operator. The resulting data type of the expression must be a scalar integer or floating-point value. If the result is 0, the expression is considered to be FALSE; otherwise, it is TRUE.

Note: Blanks are optional around operators and operands unless their omission causes an ambiguity. An ambiguity typically occurs only with the word form of an operator (such as AND, OR, IN, and LIKE). With these operators, a blank or separator, such as a parenthesis or bracket, is required to distinguish the word operator from an operand. For example, aANDb is ambiguous. It is unclear if this is intended to be the variable name aANDb or the variable names a and b combined with the AND operator. It is actually interpreted by the application as a single variable name aANDb. With non-word operators (such as +, -, =, &&, and so on) this ambiguity does not exist, and therefore blanks are optional.
Table 1 summarizes the set of operators that can be used in expressions.
Table 1. Operators that can be used in expressions
Operator Description Left data types Right data types Example Notes
+ Addition float, integer float, integer "1+2" results in 3  
- Subtraction float, integer float, integer "1.0-2.0" results in -1.0  
* Multiplication float, integer float, integer "2*3" results in 6  
/ Division float, integer float, integer "2/3" results in 1  
- Unary minus None float, integer "-abc"  
+ Unary plus None float, integer "+abc"  
.. Range integer integer "1..3" results in 1,2,3 This is a shorthand notation for all integers between and including the two values.
% Modulo integer integer "10%2" results in 0  
| Bitwise OR integer integer "2|4" results in 6  
& Bitwise AND integer integer "3&2" results in 2  
~ Bitwise complement None integer ~0x0000ffff results in 0xffff0000  
^ Exclusive OR integer integer 0x0000aaaa^0x0000ffff results in 0x00005555  
>> Right shift integer integer 0x0fff>>4 results in 0x00ff  
<< Left shift integer integer "0x0ffff<<4" results in 0xffff0  

==

=
Equality All (except float and SD) All (except float and SD)
"2==2"  results in 1

"2=2"  results in 1
The result is 0 (FALSE) or 1 (TRUE).
!=

<>
Inequality All (except SD) All (except SD)
"2!=2"  results in 0

"2<>2" results in 0
The result is 0 (FALSE) or 1 (TRUE).
> Greater than float, integer float, integer "2>3" results in 0 The result is 0 (FALSE) or 1 (TRUE).
>= Greater than or equal float, integer float, integer "4>=3" results in 1 The result is 0 (FALSE) or 1 (TRUE).
< Less than float, integer float, integer "4<3" results in 0 The result is 0 (FALSE) or 1 (TRUE).
<= Less than or equal float, integer float, integer "2<=3" results in 1 The result is 0 (FALSE) or 1 (TRUE).
=~ Pattern match string string "abc"=~"a.*" results in 1 The right operand is interpreted as an extended regular expression.

To use this operator in an expression, the locales of the nodes running the RMC daemon must be using either Unicode Transfer Format-8 (UTF-8) encoding, a codeset that matches UTF-8, or C locale encoding. If multiple nodes are involved, the encoding must be consistent across all nodes.

!~ Not pattern match string string "abc"!~"a.*" results in 0 The right operand is interpreted as an extended regular expression.

To use this operator in an expression, the locales of the nodes running the RMC daemon must be using either Unicode Transfer Format-8 (UTF-8) encoding, a codeset that matches UTF-8, or C locale encoding. If multiple nodes are involved, the encoding must be consistent across all nodes.

=?

LIKE

like
SQL pattern match string string "abc"=? "a%" results in 1 The right operand is interpreted as an SQL pattern.
!?

NOT LIKE

not like
Not SQL pattern match string string "abc"!? "a%" results in 0 The right operand is interpreted as an SQL pattern.
|<

IN

in
Contains any All (except SD) All (except SD) "{1..5}|<{2,10}" results in 1 The result is 1 (TRUE) if the left operand contains any value from the right operand.
><

NOT IN

not in
Contains none All (except SD) All (except SD) "{1..5}><{2,10}" results in 0 The result is 1 (TRUE) if the left operand contains no value from the right operand.
&< Contains all All (except SD) All (except SD) "{1..5}&<{2,10}" results in 0 The result is 1 (TRUE) if the left operand contains all values from the right operand.
||

OR

or
Logical OR integer integer "(1<2)||(2>4)" results in 1 The result is 0 (FALSE) or 1 (TRUE).
&&

AND

and
Logical AND integer integer "(1<2)&&(2>4)" results in 0 The result is 0 (FALSE) or 1 (TRUE).
!

NOT

not
Logical NOT None integer "!(2==4)" results in 1 The result is 0 (FALSE) or 1 (TRUE).

When integers of different signs or size are operands of an operator, standard C-style casting is implicitly performed. When an expression with multiple operators is evaluated, the operations are performed in the order defined by the precedence of the operator. The default precedence can be overridden by enclosing the portion or portions of the expression to be evaluated first in parentheses (). For example, in the expression "1+2*3", multiplication is normally performed before addition to produce a result of 7. To evaluate the addition operator first, use parentheses as follows: "(1+2)*3". This produces a result of 9.

Table 2 shows the default precedence order for operators in expressions. All operators in the same table cell have the same or equal precedence.
Table 2. Operator precedence in expressions, from highest to lowest
Operators Description
. Structured data element separator
~

!
NOT
not

-

+
Bitwise complement

Logical not



Unary minus

Unary plus
*

/

%
Multiplication

Division

Modulo
+

-
Addition

Subtraction
<<

>>
Left shift

Right shift
<

<=

>

>=
Less than

Less than or equal

Greater than

Greater than or equal
==    

!=

=?  
LIKE
like

!?

=~

!~

?=

|<
IN
in

><
NOT IN
not in

&<
Equality

Inequality

SQL match



SQL not match

Regular expression match

Regular expression not match

Regular expression match (compact)

Contains any



Contains none



Contains all
& Bitwise AND
Bitwise exclusive OR
| Bitwise inclusive OR
&& Logical AND
|| Logical OR
, List separator