Precedence

If several operators exist in a single expression and parentheses have not been used then the expression is evaluated in a strict order. This order is known as "operator precedence"
When operators have the same precedence they are evaluated from left-to-right.
Parentheses can be used to overwrite the order and to evaluate certain parts of the expression. Operations inside parentheses are always performed before those outside.
When a series of operators appear in the same expression there is a strict order in which they will be evaluated.
The rules of precedence tell the compiler which operators to evaluate first.
Parentheses can obviously be used to change the order of precedence.
Operators are evaluated in the following order: Mathematical, Concatenation, Relational, Logical.


OrderSymbolOperator
1^Exponentiation
2-Negation
3*Multiplication
3/Division with Decimal result
4\Division with Integer result
5ModModulo
6+Addition
6-Subtraction
7&String Concatenation
8=Equal or Assignment
8<>Not Equal To
8<Less Than
8>Greater Than
8<=Less Than or Equal To
8>=Greater Than or Equal To
9NOTNot
10ANDAnd
11OROr
12XORExclusive OR
13EQVEquivalence
14IMPImplication

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext