we have seen Some of the bitwise operators like Complement, AND, OR

still, there are 3 bitwise operators to know

Operators | Symbols |
---|---|

Complement | ~ |

Or | | |

And | & |

XOR | ^ |

Left shift | << |

Right shift | >> |

## XOR operator

For the XOR operator, we are using the symbol called **Cap ^**

## Example

```
print(25^30)
```

## Output

7

## Understanding the XOR operator

here we can see what the XOR operator is doing

When both of the 2 inputs are the same we will get 0 (FALSE) as output

**Case 1**(**SAME)**- if both the inputs are 0 and 0 We will get the output as 0
- if both the inputs are 1 and 1 We will get the output as 0

**Case 2 (Different)**- if one of the input is 1 and other is 0 We will get the output as 1
- if one of the input is 0 and other is 1 We will get the output as 1

## Explanation

here we are printing value by performing the XOR operator for the numbers 25 and 30

and we are getting the output as 7

So what’s happening behind the code?

To understand that we need to know about the bit operations

if you don’t know check it out *here*

## Behind the code

25 in binary can be written as 00011001 30 in binary can be written as 00011110 By performing XOR operations we will get -------------- 00000111 which will be equal to7

this is why we are getting 7 as output ✔

## Left Shift operator

For the Left Shift operator, we are using the symbol called **Double lesser than symbol ****<< **

## Example

```
print(8<<1)
print(8<<2)
```

## Output

16 32

## Understanding the Left shift operator

here we can see what the Left shift operator is doing

## Syntax

```
Number << number of Shifting
```

## Explanation

**Case 1**(**Number of shift = 1)**- Firstly Convert number into binary form
- Then for left shift
**Add one zero bit to right side at left most bit (LSB)** - then convert that shifted bits into integer form we will get the output

**Case 2 (Number of shift = 2 )**- Firstly Convert number into binary form
- Then for left shift
**Add two zero bits to right side at left most bit (LSB)** - then convert that shifted bits into integer form we will get the output

## Explanation

here we are printing value by performing the Left shift operator for the number 8 and performing 1 shift and 2 shifts and we are getting the output as 16 and 32 respectively

## Right Shift operator

For the Right Shift operator, we are using the symbol called **Double Greater than symbol **>>

## Understanding the Right shift operator

The right shift operator is similar to that of the left-shift operator that we have seen before

## Syntax

```
Number >> number of Shifting
```

## Explanation

**Case 1**(**Number of shift = 1)**- Firstly Convert number into binary form
- Then for left shift
**remove one bit from Right side at left most bit (MSB)** - then convert that shifted bits into integer form we will get the output

**Case 2 (Number of shift = 2 )**- Firstly Convert number into binary form
- Then for left shift
**Remove two bit from Right side at left most bit (MSB)** - then convert that shifted bits into integer form we will get the output