Appendix C
Operators
Also see Appendix G for the order of precedence.
|
Operator |
Type |
Function |
|---|---|---|
|
+ |
Math |
Addition |
|
– |
Math |
Subtraction |
|
* |
Math |
Multiplication |
|
/ |
Math |
Division |
|
% |
Math |
Modulo |
|
++ |
Math |
Increment |
|
-- |
Math |
Decrement |
|
+ |
Math |
Unary plus |
|
- |
Math |
Unary minus |
|
= |
Assignment |
Assigns a value to a variable |
|
+= |
Assignment |
Addition |
|
-= |
Assignment |
Subtraction |
|
*= |
Assignment |
Multiplication |
|
/= |
Assignment |
Division |
|
%= |
Assignment |
Modulo |
|
!= |
Comparison |
Not equal |
|
< |
Comparison |
Less than |
|
<= |
Comparison |
Less than or equal to |
|
== |
Comparison |
Is equal to |
|
> |
Comparison |
Greater than |
|
>= |
Comparison |
Greater than or equal to |
|
?: |
Ternary |
Either-or decision |
|
. |
Structure |
Member |
|
-> |
Structure |
Member of a pointer structure |
|
&& |
Logical |
Both comparisons are true |
|
|| |
Logical |
Either comparison is true |
|
! |
Logical |
The item is false |
|
& |
Bitwise |
Mask bits |
|
| |
Bitwise |
Set bits |
|
^ |
Bitwise |
Exclusive or (XOR) |
|
<< |
Bitwise |
Shift bits to the left |
|
>> |
Bitwise |
Shift bits to the right |
|
~ |
Unary |
One’s complement |
|
! |
Unary |
NOT |
|
* |
Unary |
Pointer (peeker) |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access