Operator Precedence


The following tables show the order in which operators are evaluated. Please note the following.
o Summary table.
o Table in detail.
o Operators listed by type.

Summary precedence table.

All operators on the same line have the same precedence. The first line has the highest precedence.

() [] -> .
! ~ ++ -- + - * & sizeof
* / %
+ -
<< >>
< <= >= >
== !=
&
^
|
&&
||
?:
= += -= *= /= %= &= ^= |= <<= >>=
,

Lary Huang has told me that the postfix unary -- and postfix unary ++ have a higher precedence than the prefix unary -- and prefix unary ++.


Detailed precedence table.

All operators in the same 'block' have the same precedence. The first block has the highest precedence.

GroupOperatorDescriptionExample
Membership.
()Function call.count = function(4,3);
[]Array.value = array[5] + increment;
->Structure pointer.
.Structure member.
Unary.
!Logical NOT
~
++Increment.
--Decrement.
+
-
*Pointer to data
&Address of a variable.
sizeof
(type)type cast.
Binary.
* Multiply.
/ Divide.
% Modulo.
Binary.
+ Addition
- Subtraction.
Bitwise
<< Shift left.
>> Shift Right.
Relational.
< Less than.
> Greater than.
<= Less than or equal too.
>= Greater than or equal too.
== Equal too.
!= Not equal too.
More Bitwise
& bitwise AND
^ bitwise Excusive OR
| bitwise OR
Logical.
&& Logical AND
Logical.
|| Logical OR
Conditional
? : Conditional construct.
Assignment
= Equals
+= assignment
-= assignment
*= assignment
/= assignment
%= assignment
&= assignment
^= assignment
|= assignment
<<= assignment
>>= assignment
Series
, Comma


See also:

o
Expressions and operators.
o Assignment Operators.


Top Master Index Keywords Functions


Martin Leslie