Skip to main content

Operator Precedence

Description

    When several operations occur in a single expression, each operation is evaluated and resolved in a predetermined order. This called the order of operation or operator precedence. There are three main categories of operators; arithmetic, comparison, and logical. If an expression contains operators from more than one category, arithmetic operators are evaluated first, comparison operators next, and finally logical operators are evaluated last. If operators have equal precedence, they then are evaluated in the order in which they appear in the expression from left to right. Comparison operators all have equal precedence.         The following table gives the operator precedence for each operator in each category. Operators lower on the list have a lower operator precedence. Parentheses can be used to override operator precedence. Operations within parentheses are performed before other operation. However, within the parentheses operator precedence is used.

ArithmeticComparisonLogical
- (Negation)=    <>  
 \<    \>   \<=  
 \>= | AND |

| *, / (Multiplication and division) | | OR | | MOD (Modulus Operator) | | XOR | | <<, >> (Shift Bit Left and Shift Bit Right) | | NOT | | +, - (Addition and subtraction) | | | | | | | | |   |   |

See also