# Operator priority

In QM, binary operators belong to 3 priority classes. At first are calculated arithmetic and bitwise operators, then comparison operators, then logical operators. Operators that belong to the same priority class are calculated from left to right. Parentheses can be used to change this order.

The two example statements below are equivalent (will be calculated in same order). In the second example, complex expression is broken into several single-operator expressions (primary expressions).

```result = a+b*c < d+e and f > g*h or i = j
result = (((((a+b)*c) < (d+e)) and (f > (g*h))) or (i = j))```

Unary operators are applied before binary operators, but after operators . (member access) and [] (array element access).

QM bug: expressions containing both or and and operators without enclosing are evaluated incorrectly. For example, out (1 or 0 and 0) is 1 (must be 0). Enclose parts, like out ((1 or 0) and 0). For backward compatibility it is not fixed, but QM detects such expressions and shows warning.