When an application computes a formula with multiple operators, it follows strict prioritization rules. Understanding these rules will help you compose correct formulas without errors and get the expected results.
Order of operations
1.First, expressions within parentheses ( ) are evaluated. Within the parentheses, the standard priority rules apply. If the parentheses are nested, calculations start from the innermost parentheses.
2.Then the operations are executed according to their priority (see the table below).
3.Operators with the same priority are calculated from left to right.
An example of calculating a formula
The formula = A1 + B1 * C1 may produce a non-obvious result. Since multiplication (*) has a higher priority than addition (+), B1 * C1 will be calculated first, and then the result will be added to A1. If you wanted to add A1 and B1 first, you must use parentheses: = (A1 + B1) * C1.
Operator priorities
The operators in the table are listed from the highest priority (executed first) to the lowest.
Priority |
Operator |
Description and example of use |
|---|---|---|
1 |
() |
Parentheses. Forces the order of calculations. Example: =(A1+5)*B1 |
2 |
- (unary) |
Unary minus. Denotes a negative number. |
3 |
% |
Percentage. Calculating percent. |
4 |
^ |
Elevation to a degree. |
5 |
* and / |
Multiplication and division. |
6 |
+ and - |
Addition and subtraction. |
7 |
& |
Combining (concatenating) text. |
8 |
, <>, <, <=, >, >= |
Comparison operators. Returns the values True or False. |
Parentheses
If you are in doubt about the order of calculations or just want to make the formula clearer, feel free to use parentheses. Superfluous brackets will never lead to an error, and their presence will make your logic crystal clear both for the application and for other users.