Operators play an important role in the Quickbase formula language. Operators are special symbols like + and * that act upon one or two values to return a new value. They tell Quickbase what you want to do with the values in your formula. There are two types of operators:
Unary operators operate on a single value, and are written like -4 or +5. (See a list of unary operators.)
Binary operators operate on two values, and are written like 3 + 4, and 23.4 – 0.4. (See a list of binary operators.)
Rules of Operator Precedence
Quickbase doesn't evaluate a formula in a random order. It doesn't even evaluate a formula from left to right, as many people imagine. Instead, operators have a predefined order of precedence. In other words, Quickbase acts on certain operators before it acts upon others. For example, * has higher precedence than +. This means that the expression 3+4*2 evaluates to 11, not 14.
Tip: To manually control operator precedence, enclose portions of your formula in parentheses. Quickbase always evaluates operators within parentheses first and treats the result as a single value before moving on to the rest of the formula. (Read more in the Formula foundations help article.)
In the following table, operators are listed from highest precedence to lowest precedence.
|Precedence Level||Operator||Evaluation Order in Expressions|
|1 (highest)||unary +, unary -, not||Right to left|
|2||^||Left to right|
|3||*, /||Left to right|
|4||binary +, binary -, &||Left to right|
|5||<, >, <=, >=||Left to right|
|6||=, <>, !=||Left to right|
|7||and||Left to right|
|8 (lowest)||or||Left to right|
When binary operators of the same precedence appear next to each other, they are evaluated left to right. When unary operators appear next to each other they are evaluated right to left.
For example, the following expressions are equivalent, and they return the Boolean value true.
3 < 2 + 1 / 5 + --3 and 8 > 3
(3 < ((2 + (1 / 5)) + (-(-3)))) and (8 > 3)