> The function of this symbol is to shift all the bits of an integer to the right by the specified number of bits. Extra bits beyond the right boundary will " />
Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - "> > What's the use of this symbol?
"> > What's the use of this symbol?
"> > The function of this symbol is to shift all the bits of an integer to the right by the specified number of bits. Extra bits beyond the right boundary will be discarded and a binary bit will be removed from the left boundary. If the highest bit of the original number is 1, then the shifted binary bit is 1, otherwise it is 0. Represents the right shift operator, which is equivalent to "shr". This operator is a binocular operator and the combination direction is from left to right.

Extended data:

In js, left shift is logical/arithmetic left shift (both are exactly the same), and right shift is arithmetic right shift, which will keep the sign bit unchanged. In practical application, we can use left/right shift to do fast multiplication/Divison according to the situation, which is much more efficient than loop.

When shifting, all the shifted digits are discarded, and the number of shifting vacancies is related to the left or right shift. If it is left shift, it is stipulated that all the added numbers are 0; If it is shifted to the right, it is also related to whether the shifted data has a sign. If there are unsigned numbers, all the added numbers are 0; If it is a signed number, all the added numbers are equal to the original number of the leftmost bit of the original number (that is, the original sign bit).

Baidu encyclopedia-> >;

Baidu Encyclopedia-Right Shift Operator