operators

# TTCN-3 operators

TTCN-3 supports a number of predefined operators that may be used in the terms of TTCN-3 expressions. The predefined operators fall into seven categories:

1. arithmetic operators;
2. string operators;
3. relational operators;
4. logical operators;
5. bitwise operators;
6. shift operators;
7. rotate operators.

These operators are listed in the following table:

Category | Operator | Symbol or Keyword
--- | --- | ---
Arithmetic operators | addition | +
substraction | -
multiplication | *
division | /
modulo | mod
remainder | rem
String operators | concatenation | &
Relational operators | equal | ==
less than | <
greater than | >
not equal | !=
greater than or equal | >=
less than or equal | <=
Logical operators | logical not | not
logical and | and
logical or | or
logical xor | xor
Bitwise operators | bitwise not | not4b
bitwise and | and4b
bitwise or | or4b
bitwise xor | xor4b
Shift operators | shift left | <<
shift right | >>
Rotate operators | rotate left | <@
rotate right | @>

The precedence of these operators is shown in the table below. Within any row in this table, the listed operators have equal precedence. If more than one operator of equal precedence appears in an expression, the operations are evaluated from left to right. Parentheses may be used to group operands in expressions, in which case a parenthesized expression has the highest precedence for evaluation.

Priority | Operator type | Operator
--- | --- | ---
highest |  | ( ... )
| Unary | +, -
Binary | *, /, mod, rem
Binary | +, -, &
Unary | not4b
Binary | and4b
Binary | xor4b
Binary | or4b
Binary | <<, >>, <@, @>
Binary | <, >, <=, >=
Binary | ==, !=
Unary | not
Binary | and
Binary | xor
lowest | Binary | or