Skip to content

Operator Precedence

MarekBykowski edited this page May 26, 2026 · 1 revision
Level Operators Note
1 (highest) () [] -> . postfix++ -- always wins
2 prefix++ -- * & ! ~ sizeof right→left
3–4 * / % + - arithmetic
5 << >> shifts
6–7 < <= >= > == != == is above & !
8 & bitwise AND
9 ^ bitwise XOR
10 | bitwise OR
11–12 && || logical
14 (lowest) = += -= assignment
// TRAP — == binds tighter than &
val & 0x01 == 0      // → val & (0x01==0) → val & 0 → always 0!
(val & 0x01) == 0    // correct

// TRAP — postfix++ beats *
*p++    // → *(p++) — deref old p, then advance
(*p)++  // increment the value p points to

Clone this wiki locally