# Bitwise Operator

• Bitwise operator work on bits
• Turbo c is a 16 bit compiler. Due to this the bitwise operator are limited to 16 bits only.
• Bitwise operators only on integer type value.
• When the first bit [sign bit] is ‘1’ then the number is negative or ‘O’ then the number is positive.

#### Note:

Bitwise operators are with label feature.

C language supports the following bitwise operators.

& – Bitwise and

| – Bitwise or

^ – xor, Exclusive or

~ – Complement operator

<< – Left shift operator

>> – Right shift operator

#### & – Bitwise and: –

In this both bits are 1βs then result bit is β1β then otherwise result bit is β0β.

Ex: –

25 & 15 = 9

#### | – Bitwise or

In this both bits are 0βs then result bit is 0 otherwise result bit is 1.

Ex: –

25 | 15=31

#### ^ – xor, Exclusive or Operator

In this both bits are same then result bit is β0β otherwise result bit is β1β.

Ex: –

25 ^ 15=22

#### ~ – Complement operator:-

In complement operator the bit are complimented.

i.e 1βs become 0βs and 0βs become 1βs. due to this +ve number become βve and -ve number +ve.

EX:-

~ +25 == > -26

~ -25 == >+24

<< – Left shift operator:-

In left shift operator the specified number of bit are deleted from left side and the same number of zeros are added on right side. In left shift operation, most operation, most probable the value is multiplied with 2 that number of times.

Ex; –

25<<1=50

25<<2=100

25<<15=32768

25<<16=0

#### >> – Right shift operator:-

In right shift operator the bits are moved to right side.

I.e. the specified number of bits is deleted from right side and same number of zeroβs is added left side. Due to this always the number is divided with 2 that number of time.

Ex:-

25>>1=12

25>>2=6

25>>3=3

25>>4=1

25>>5=0

#### Author: E-Learning

We would be happy to hear from you about the topics you would like to read on this blog of ours. So, please donβt hesitate to contact us with queries, suggestions, feedback, etc.