C # section of the shift operator (1)
Left shift operator (<)
Move the first operand to the left and the number of digits specified by the second operand. For example, 1100100 <2 = 110020.,1100100 shifted left to 1100100 ports, and 110010000 after 0.
Right Shift Operator (<)
Move the first operand to the right to the number of digits specified by the second operand, and fill in 0 for the null position. For example: 1100100> 2 = 0011001,1100100 after the right shift of two digits, the mouth is 11001, and after 0 is filled, the mouth is 0011001.
Interesting things
In the decimal system, the Left shift is equivalent to adding a 0, that is, increasing the first square of 10, and the left shift is adding two zeros, that is, expanding the second square of 10. Similarly, in the binary system, a 0 value is added to shift the first digit to the left, that is, the doubling of the first digit of 2 is increased, and the two digits to the left are added with two zeros, Which is doubled by the second element of 2, then there is the following relationship:
N <1, equivalent to n * 2
N <2, equivalent to n * 4
N <3, equivalent to n * 8
N <4, equivalent to n * 16
Similarly, the right shift is expressed:
N> 1, equivalent to n/2
N> 2, equivalent to n/4
N> 3, equivalent to n/8
N> 4, equivalent to n/16