Bit operators
~
int a= 3;
a -> 0000 0000 0000 0000 0000 0000 0000 0011
~a -> 1111 1111 1111 1111 1111 1111 1111 11 00
& bit logic has zero, get zero ----> Clear operation
int a= 3; a:0011
int b= 5; b:0101
a&b : 0001
| One with operation gets one ---->Set one operation
int a= 3; a:0011
int b= 5; b:0101
a|b : 0111
^ Bit logical XOR returns 0 if they are the same, 1 if they are different
int a= 3; a:0011
int b= 5; b:0101
int c=a^b;
printf("c:%d\n",c); // 6
printf("c^a:%d\n",c^a); // 3 ---->a
printf("c^b:%d\n",c^b); //5 ----->b
<< The left- shifted items are directly discarded, and the empty ones are filled with 0.
int a=3;
a -> 0000 0000 0000 0000 0000 0000 0000 0011
a <<4 0000 0000 0000 0000 0000 0000 0011 0000
int a=-3; //Negative numbers are stored in memory using complement code
a -> 1000 0000 0000 0000 0000 0000 0000 0011
Tori // 1111 1111 1111 1111 1111 1111 1111 1100
Complement code plus 1 // 1111 1111 1111 1111 1111 1111 1111 1101
a <<4 1111 1111 1111 1111 1111 1111 1101 0000 // -48
-48 // 1000 0000 0000 0000 0000 0000 0011 0000
Tori // 1111 1111 1111 1111 1111 1111 1100 1111
Plus one // 1111 1111 1111 1111 1111 1111 1101 0000
>>Move right
int a=3;
a -> 0000 0000 0000 0000 0000 0000 0000 0011
a >>4 0000 0000 0000 0000 0000 0000 0000 0000