Format: Number to shift.
For example: 3
When 3 is converted into binary, it is 00 1 1. All the numbers are shifted two places to the left, and the spaces are filled with 0, so that 1 100 is obtained, that is, the decimal number 12.
2. right shift operator (>>): shift all numbers to the right by the corresponding shift digits in binary, move out (discard) the low digits, and fill in the sign digits of the high digits (positive digits are filled with zeros, negative digits are filled with 1).
Format: Number to Move >> Number of shifts
For example:11>; & gt2
The binary of 1 1 is1kloc-0/1,and all numbers are shifted to the right by two places. Because 1 1 is a positive number, the high-order complement result of 0 is 00 10, which is a decimal 2.
Extended data:
The shift operator is a bit operation operator. The shift operator can shift numbers on a binary basis. According to the direction of translation and the rules of filling in numbers, there are three kinds:> (signed right shift) and >; & gt& gt (unsigned right shift).
Mathematical significance:
1. On the premise that the number does not overflow, whether it is positive or negative, moving one place to the left is equivalent to 2 times 1 power, and moving n places to the left is equivalent to 2 times n power.
2. Moving 1 bit to the right is equivalent to dividing by 2, and moving n bits to the right is equivalent to dividing by 2 to the n power.