Tuesday, 10 June 2014

Bitwise operators

Bitwise operators: performs operation on the bit level. These operator include è bitwise AND, bitwise OR, and Bitwise XOR.

Bitwise AND(&):               example:
                                                10101010 & 01010101 = 00000000
                In a C program, the & operator is used as follows.
                                int a=10,b=20,c=0;
                                c=a&b;

Bitwise OR( | ):
                                example:
                                                10101010 | 01010101 = 11111111
                                                In a C program.
                                                c = a|b;

Bitwise XOR( ^ ):
                                Example:
                                                10101010 ^ 01010101 = 11111111
                                                In a C program:
                                                c= a^b;
Bitwise NOT( ~ ):

 ~10101111 = 01010000

No comments:

Post a Comment