Home > Article > Backend Development > c language bit operators
Bitwise operators allow processing of individual bits within a byte or larger unit of data: any bit or bits can be cleared, set, or inverted. You can also shift the bit pattern of an integer to the right or left.
1. "&"
Bitwise AND operation, perform "AND" operation based on binary bits. Operation rules:
0&0=0; 0&1=0; 1&0=0; 1&1=1;
2, "|"
Bitwise OR operator, perform "OR" operation based on binary bits. Operation rules:
0|0=0; 0|1=1; 1|0=1; 1|1=1;
3, "^"
XOR operator, performs "XOR" operation based on binary bits. Operation rules:
0^0=0; 0^1=1; 1^0=1; 1^1=0;
4, "~"
Negation operator, performs "inversion" operation based on binary bits. Operation rules:
~1=0; ~0=1;
5, "96ef5a3f369077d16e8f68c26d34bb54>"
Binary right shift operator. Shift all the binary digits of a number to the right by a certain number of bits. Positive numbers are padded with 0s on the left, negative numbers are padded with 1s on the left, and the right sides are discarded.
A >> 2 will get 15, which is 0000 1111
The above is the detailed content of c language bit operators. For more information, please follow other related articles on the PHP Chinese website!