A special type of operators are parentheses, which enclose expressions within expressions. Proper use of parentheses can alter the order of processing in an expression, altering the default precedence. The table below identifies the precedence of MapBasic operators. Operators which appear on a single row have equal precedence. Operators of higher priority are processed first. Operators of the same precedence are evaluated left to right in the expression (with the exception of exponentiation, which is evaluated right to left).
Priority | MapBasic Operator |
---|---|
(Highest Priority) |
parenthesis |
exponentiation |
|
negation |
|
multiplication, division, Mod, integer division |
|
addition, subtraction |
|
geographic operators |
|
comparison operators, Like operator |
|
Not |
|
And |
|
(Lowest Priority) |
Or |
For example, the expression 3 + 4 * 2 produces a result of 11 (multiplication is performed before addition). The altered expression (3 + 4) * 2 produces 14 (parentheses cause the addition to be performed first). When in doubt, use parentheses.