Java in think has the following sentence:
If char, byte, or short is displaced, they are automatically converted to an int before the shift. Only the five low positions on the right can be used. This prevents us from moving the unrealistic digits in an int number.
In the above sentence, the object operated by the shift operator is the binary "bit", and the int type is 32 bits, that is, the 32 power of 2. If you move more than 32 bits, all the original data will disappear, which makes no sense.
So the above "only the five low positions on the right will be useful" means that the lower five digits of the shift operator's right side (converted to binary) will be useful, that is, x <y indicates that y can be used only when its 5th bit is low, that is, it cannot be greater than 32. The same applies to long.
Therefore, if you shift an int type, x <Y;
When Y is less than 32, the result after the shift is generally in the range that can be expressed. Then, convert Y to the binary number, and then take the lower five digits of the binary number, then convert the five digits into decimal digits, which is the number of digits to be moved to X.
For example, int A = 140;
System. Out. println (integer. tobinarystring (A <34 ));
The execution process of the preceding statement is:
First, convert a into a binary number: 1000 1100
When executing Statement A <34, convert 34 to binary 10 0010 first, and convert the binary number to a decimal number 2 with a lower value of 5 digits of 0 0010, therefore, it is actually two shifts to the left of.
Now everyone on Earth knows that the result is: 10 0011 0000