Precedence is a priority of the operator for evaluation or execution when there are more then 1 operator in a single expression or statement. If there are operators of same precedence then the expression will evaluated either from LEFT-TO-RIGHT or RIGHT-TO-LEFT. This is called an associativity of an operator.
Description | Operator | Associatively | Precedence |
Function Expression | () | L TO R | 1 |
Array expression | [] | L TO R | |
Structure operator | -> | L TO R | |
Structure operator | . | R TO L | |
Unary minus | - | R TO L | 2 |
Increment/Decrement | ++-- | R TO L | |
One’s complement | R TO L | ||
Negation | ! | R To L | |
Address of | & | R To L | |
Value of address | * | R TO L | |
Type cast | (type) | R To L | |
Size in bytes | Size of | R TO L | |
Multiplication | * | L To R | 3 |
Division | / | L TO R | |
Modulus | % | L TO R | |
Addition | + | L TO R | 4 |
Subtraction | - | L To R | |
Left shift | << | L TO R | 5 |
Right shift | >> | L TO R | |
Less than | < | L TO R | 6 |
Less than equal to | <= | L TO R | |
Greater than | > | L To R | |
Greater than equal to | >= | L To R | |
Equal to | = = | L TO R | 7 |
Not equal to | != | L TO R | |
Bitwise and | & | L TO R | 8 |
Bitwise exclusive or | ^ | L TO R | 9 |
Logical AND | && | L To R | 11 |
Logical OR | || | L TO R | 12 |
Condition | ?: | R To L | 13 |
Assignments | =*, =,/=, %=, +=.-=, ^=, |=, &=, <<=, >>= | R TO L | 14 |
Comma | , | R TO L | 15 |
0 comments:
Post a Comment