Operation | Symbol | Associativitya | Usage | Precedenceb |
grouping | () | left to right | (a); | 1 |
function call | name() | left to right | name(a); | 1 |
index operation | [] | left to right | [a]; | 1 |
postfix increment/decrement | ++ -- | left to right | a++; a--; | 1 |
deference operation | * | right to left | *a; | 2 |
reference operation | & | right to left | &a; | 2 |
sign | + - | right to left | +a; -a; | 2 |
boolean negation | ! | right to left | !a; | 2 |
bitwise negation | ~ | right to left | ~a; | 2 |
prefix increment/decrement | ++ -- | right to left | ++a; --a; | 2 |
multiplication/division/modulo | * / % | left to right | a*b; a/b; a%b; | 3 |
addition/subtraction | + - | left to right | a+b; a-b; | 4 |
shift operation | << >> | left ot right | a<<b; a>>b; | 5 |
relation operation | < <= > >= | left to right | a<b; a<=b; a>b; a>=b; | 6 |
equality operation | == != | left to right | a==b; a!=b; | 7 |
bitwise AND operation | & | left to right | a&b; | 8 |
bitwise XOR operation | ^ | left to right | a^b; | 9 |
bitwise OR operation | | | left to right | a|b | 10 |
boolean AND operation | && | left to right | a&&b; | 11 |
boolean OR operation | || | left to right | a||b; | 12 |
conditional operator | ?: | right to left | a?b:c; | 13 |
assignment | = | right to left | a=b; | 14 |
operational assignmentc | *= /= += etc. | right to left | a+=b; a/=b; a+=b; etc | 14 |
comma operator | , | left to right | a,b; | 15 |
bOperation with lower precedence are evaluate before those with higher. Example: 3 * (4 +5) calculates first the bracket (precedence 1) before multiplying the result with 3 (precedence 3). Without the brackets the multiuplication comes before the addition (precedence 4).
cOperational assignment a (operator)=b is identical to a=a (operator) b. The allowed operational assignment are: +=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=.
css_footer(); ?>