Bitwise Operators
An Bitwise operator is used for the manipulation of data at the bit level. These operators are not applied for the float and double datatype.
Bitwise operator first converts the integer into its binary representation then performs its operation. Bitwise operators subsist of two digits, either 0 or 1. Some of the bitwise operators are (&, | , ^, ~)
Note: Shift Bitwise operators are used to shift the bits right to left. Some of the shift bitwise operators are(<<, >>)
SIMPLE C PROGRAMMING USING BITWISE OPERATORS
// C program to illustrate the bitwise operators
#include <stdio.h>
int main()
{
int a = 25, b = 5;
// using operators and printing results
printf("a & b : %d\n", a & b);
printf("a | b : %d\n", a | b);
printf("a ^ b : %d\n", a ^ b);
printf("~a : %d\n", ~a);
printf("a >> b : %d\n", a >> b);
printf("a << b : %d\n", a << b);
return 0;
}
Output
a & b : 1
a | b : 29
a ^ b : 28
~a : -26
a >> b : 0
a << b : 800
