Bitwise Operators Summary
Lesson 8 of 17 in Coddy's Bit Manipulation course.
Okay so now we know what bit manipulation is. We use bitwise operators to manipulate bits. Lets recap the operators we learned.
Bitwise Operators
A bitwise operator is used to perform bitwise operations on bit patterns or binary numbers that involve the manipulation of individual bits. Again a bit represents either 0 or 1. So, bitwise operators takes in account these sequence of bits and manipulate them. One thing to note here is that throughout this course we will only be dealing with unsigned numbers ( an unsigned number has only magnitude, basically positive numbers only ) .
Now C++ offers several different bitwise operators.
Operator name | Operator represented by | Number of operands |
Bitwise NOT | ~ | 1 |
Bitwise OR | | | 2 |
Bitwise AND | & | 2 |
Bitwise XOR | ^ | 2 |
Bitwise left shift | << | 2 |
Bitwise right shift | >> | 2 |
The above table shows what bitwise operators C++ offers and the symbol used that identify them and the number of operands they operate on.
Try it yourself
This lesson doesn't include a code challenge.
All lessons in Bit Manipulation
1Introduction and basics
What is bit manipulation?Why we need bit manipulation?Binary and decimal numbersNOT & OR operatorsAND operatorXOR operatorRight and left shift operatorsBitwise Operators Summary