Bitwise Operator

bitwise operator in c language
  • 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.


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 and Operator

| – Bitwise or

In this both bits are 0’s then result bit is 0 otherwise result bit is 1.

Ex: –

25 | 15=31

| - Bitwise or Operator

^ – xor, Exclusive or Operator

In this both bits are same then result bit is β€˜0’ otherwise result bit is β€˜1’.

Ex: –

25 ^ 15=22

^ - xor, Exclusive or Operator

~ – 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.


~ +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; –





>> – 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.







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.

Leave a Reply

Your email address will not be published. Required fields are marked *