1. Shift operators: Operators << and operator >> operands can be any integer or character type. An integral elevation is performed on two operands, and the type returned is the type of the left operand promoted.
The value of the i<<j is the result of moving the bits in I to the left J-bit. Each time you overflow one bit from the leftmost end of I, fill a 0-bit at the right end of I.
The value of the i>>j is the result of shifting the bits in I to the right by the J bit. If I is an unsigned or non-negative number, the left end is required to make a 0-bit complement. If I is a negative number, the result is defined by the implementation.
For example:
unsigned int i,j;
i = 13; The binary number of I is: 0000000000001101
j = i << 2; The value of J is 52 and the binary is: 0000000000110100
j = i >> 2; The value of J is 32:0000000000000011
2. Bitwise negation operator (~) bitwise AND operator (&) bitwise OR operator (^) bitwise OR Operator (|): Each of these four operators performs a Boolean operation on each digit of the operand.
~ Operator: reverse operation on operand, replace each 0 with 1, and replace each 0 with 1;
& operator: Two operands corresponding bits perform logic and operations.
^ and | Operators: Both perform logic or operations on two operands, the difference being that when the bit of two operands is 1 o'clock, ^ produces 0 and | produces 1.
For example:
int I, j,k;
i = 21; The binary number is: 0000000000010101
j = 56; The binary number is: 0000000000111000
K = ~i; K = 655,142 number is: 1111111111101010
K = i ^ j; K = 452 System: 0000000000101101
K = i & J; K = 162 System: 0000000000010000
K = I | J; K = 612 System: 0000000000111101
Priority: from high to Low: ~ & ^ |