Precedence and associativity
If you combine several operands by using different operators, the operator precedence
defines in which order BI# will perform the operations. For example, BI# interprets
x + y * z
as x + (y * z)
, because the operator *
has a higher precedence than the operator +
.
This table lists all operators sorted by their precedence from the highest to the lowest:
Operators | Function |
---|---|
+ - ! |
Unary |
* / % |
Multiplicative |
+ - |
Additive |
< > <= >= |
Relational |
== != |
Equality |
& |
Binary AND |
^ |
Binary XOR |
| |
Binary OR |
and |
Logical AND |
or |
Logical OR |
= |
Assignment |
Associativity controls the order of operations, if you combine several operands by
using the same operator. For example, BI# interprets x + y + z
as (x + y) + z
, because the +
-operator is left-associative. At the moment all operators in BI# are left-associative.
You can always change precedence and associativity by using parentheses as in (x + y) * z
, for example.