# Understanding Operator Precedence - MapInfo_Pro - 2023

## MapInfo Pro Help

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapInfo Pro
Version
2023
Language
English
Product name
MapInfo Pro
Title
MapInfo Pro Help
First publish date
1985
ft:lastEdition
2023-09-12
ft:lastPublication
2023-09-12T16:39:16.995549

When MapInfo Pro evaluates expressions it needs to know which components of an expression to evaluate first. This is called precedence. By convention, certain operators are assigned different levels of precedence. Those with the highest level are evaluated first. The following table lists MapInfo Pro's operators in the order in which they are evaluated. Exponentiation evaluates from the right. This affects expressions with multiple exponents: 2 ^ -3 ^ -4 = 2 ^ ( - (3 ^ (-4)))

Operators at the same level of precedence are evaluated from left to right.

 Highest Priority: Parenthesis Exponentiation Negation Multiplication, Division Addition, Subtraction Geographic operators, Comparison operators Not And Lowest Priority: Or

For example, the expression 3+4*2 produces a result of 11. That is because multiplication has a higher precedence than addition and is performed first, in effect:

``````3+4*2=
3+8=
11``````

We can add parenthesis to force MapInfo Pro to do the addition first:

``````(3+4)*2=
7*2=
14``````

Now consider expression 60, which is intended to select all records July or September of 1989.

Because "and" has higher precedence than "or", MapInfo Pro treats this expression as though "year(RECEIVED)=89 and month(RECEIVED)=7" was enclosed in parentheses.

In this case, any record for July of 89 or for September of any year would be selected. That is probably not what you want. However, by adding parentheses to the second expression, you can get this:

In this expression, the parentheses tell MapInfo Pro that "month(RECEIVED)=7" and "month(RECEIVED)=9" are alternatives in the second clause of the expression. MapInfo Pro treats this the same as it treats number 53 above.

Note: When you are not sure how MapInfo Pro evaluates an expression with several operators, you should use parentheses to group elements as you want them.