Quick Google Search

Showing posts with label Precedence and Associativity of Operators. Show all posts
Showing posts with label Precedence and Associativity of Operators. Show all posts

Precedence and Associativity of Operators

Precedence and Associativity of Operators:

From highest to lowest precedence [associativity]:

--- ()  []  ->  .                                  [L to R]

--- !  ~  ++  --  +  -  *  &  (type)  sizeof       [R to L]

--- *  /  %                                        [L to R]

--- +  -                                           [L to R]

--- <<  >>                                         [L to R]

--- <  <=  >  >=                                   [L to R]

--- ==  !=                                         [L to R]

--- &                                              [L to R]

--- ^                                              [L to R]

--- |                                              [L to R]

--- &&                                             [L to R]

--- ||                                             [L to R]

--- ?:                                             [R to L]

--- =  +=  -=  *=  /=  %=  &=  ^=  |=  <<=  >>=    [R to L]

--- ,                                              [L to R]

Notes:

Operators on the same line have the same precedence
"()" refers to a function call
Unary +, - and * have higher precedence than the corresponding binary forms
Because the precedence of bitwise operators &, ^ and | is lower than that of == and !=, bit-testing expressions must be parenthesised to give proper results

Popular Posts