& Bitwise AND
| By bit or^ Bitwise OR
1. bitwise and operation bitwise AND operator "&" are binary operators. Its function is the binary phase corresponding to the two numbers involved in the operation. The result bit is 1 only when the two binary numbers are 1. Otherwise, the result bit is 0. The number of involved operations is supplemented.
For example, 9 & 5 can be written as follows: 00001001 (Binary complement of 9) & 00000101 (Binary complement of 5) 00000001 (Binary complement of 1) Visible 9 & 5 = 1. Bitwise AND operations are usually used to clear some bits or retain some bits. For example, if a clears the high eight bits of 0 and retains the low eight bits, it can be used as a & 255 operation (255 of the binary number is 0000000011111111 ).
Main (){
INt a = 9, B = 5, C;
C = A & B;
Printf ("A = % d/Nb = % d/NC = % d/N", A, B, C );
}
2. bitwise OR operator "|" is a binary operator. Its function is the binary phase or corresponding to the two numbers involved in the operation. If one of the two binary numbers is 1, The result bit is 1. The two numbers involved in the operation are supplementedCode appears.
Example: 9 | 5 writable formula: 00001001 | 00000101
00001101 (decimal 13) Visible 9 | 5 = 13
Main (){
Int A = 9, B = 5, C;
C = A | B;
Printf ("A = % d/Nb = % d/NC = % d/N", A, B, C );
}
3. bitwise exclusive or operation bitwise exclusive OR operator "^" is a binary operator. This function is used to calculate whether the binary numbers corresponding to the binary numbers are different or not. When the binary numbers of the two numbers are different, the result is 1. The number of involved operations still appears as a complement, for example9 ^ 5 can be written as follows: 00001001 ^ 00000101 00001100 (12 in decimal format)
Main (){
Int A = 9;
A = a ^ 15;
Printf ("A = % d/N", );
}