Zeros and ones ! Bits ! They can be shifted and played with too using the Bitwise Operators !

Welcome to the Newbie Programmer Series. We were discussing different types of operators and Bitwise Operators are of them. But Before I started writing this, I need to make some pre-required posts so that I can make Bitwise Operators easy to understand. We will discuss all of them now below. If you are new to this series, please go to index (click here) and read out all the previous articles so that you can easily understand what is going on below.

Bitwise Operators are very useful but their applications are very complex. I am not going to any deep detail.

**This post will only help you to get a little introduction of them, we will not study deeply, just to introduce ourselves what they are.**

Before Going into Bitwise Operators, Please checkout :

- The Binary Number System (click here)
- The Mathematical Reasoning (click here)
- and Obviously all the previous articles about operators (click here)

**Bits.**Yes those zeros and ones. By using bitwise operators, we can manipulate the ones and zeros of a value. For example we have discussed many times the OR operators. It give '1' in result when there exist at least one '1'. So on performing :

### Binary AND operator ( & )

If both bits are 1 then resulting bit is 1 otherwise 0

So here: A&B =

0011 1100

0000 1101

-------------

0000 1100

which gives (A&B) = 13 as 00001100 means 13 in Binary.

### Binary OR operator ( | )

0000 1101

-------------

0011 1101

which gives (A|B) = 61

### Binary XOR operator ( ^ )

Resulting bit is '1' only if it is set in one of the operand but not both.

So here: A^B =

0000 1101

-------------

0011 0001

which gives (A^B) = 49

### Binary NOT ( or complement ) operator ( ~ )

### Binary Left Shift Operator ( << )

### Binary Right Shift Operators ( >> )

### Using with assignment

C &= 2 is same as C = C & 2

C |= 2 is same as C = C | 2

C ^= 2 is same as C = C ^ 2

C <<= 2 is same as C = C << 2

C >>= 2 is same as C = C >> 2

That's it for today. **I will do NO programs for now as these things are already complex but we need to do an intro.** I am gonna **end operators with next post.**

So Stay Connected.

Please share this as much as you can so that we can get connected with more and more people who want to learn programming.