# Order of precedence
HyperFormula supports multiple operators that can be used to perform mathematical operations in a formula. These operators are calculated in a specific order. If the formula contains operators of equal precedence, like addition and subtraction, then they are evaluated from left to right.
# Table of precedence
In the table below you can find the order in which HyperFormula performs operations (from highest to lowest priority).
Precedence | Operator | Description |
---|---|---|
1 | : (colon) , (comma) (space) | Reference operators: range (colon), union (comma), intersection (space). Currently supported by HyperFormula only at the grammar level of a function. |
2 | – | Negation |
3 | % | Percent |
4 | ^ | Exponentiation |
5 | * and / | Multiplication and division |
6 | + and – | Addition and subtraction |
7 | & (ampersand) | Concatenation of two or more text strings |
8 | < (less than) = (equal to) > (greater than) <= (less than or equal to) >= (greater than or equal to) <> (not equal to) | Comparison |
# Using parentheses
HyperFormula calculates the formulas in parentheses first so by using them you can override the default order of evaluation. For instance, consider this formula: =7 * 8 + 2. After the equal sign, there are operands (7, 8, 2) that are separated by operators (* and +). Following the order of calculations, HyperFormula computes 7*8 first and then adds 2. The correct answer to this equation is 58.
Placing (8+2) in parenthesis will change the result as HyperFormula will first calculate 8 + 2 = 10, and after that will multiply it by 7. Now the result is 70, not 58 as in the first example.