1~ ==> bitwise NOT
2& ==> bitwise AND
3| ==> bitwise OR
4^ ==> bitwise XOR
5>> ==> bit shift right
6<< ==> bit shift left
1bitwise complement of N = ~N (represented in 2's complement form)
22'complement of ~N= -(~(~N)+1) = -(N+1)
3
1i = 14; // Bit pattern 00001110
2j = i >> 1; // here we have the bit pattern shifted by 1 thus we get 00000111 = 7 which is 14/2
3
1#include <stdio.h>
2int main(void) {
3 unsigned int a = 60; //Equal to: 0011 1100
4 unsigned int b = 13 // Equal to: 0000 1101
5
6 int both = a & b //If both are 0, then its a 0,
7 // if both are 1, then its a 1. //0000 1100
8
9 printf("%d\n", both);
10
11
12}
112 = 00001100 (In Binary)
225 = 00011001 (In Binary)
3
4Bit Operation of 12 and 25
5 00001100
6& 00011001
7 ________
8 00001000 = 8 (In decimal)