java in <<, >> and >>> meaning

<<, >>, >>> java as the shift operator.

  1. << represents a left shift operator
    e.g. << 8 2, 8 to the left represents the two, the result is 32. Low 0s.
    Binary calculation:
    Binary 8: 1000
    moves to the left as a result two 100 000, namely in terms of decimal 32 may be understood as a simple, the left is the number of large, corresponding to 8 ^ 2 * 2 = 32.
    Left shift operator operation rules: the number according to the number to the right of the left moves to the left a few.
  2. ">>" represents a right-shift operator
    , for example 8 >> 2, 2 move to the right shows a 8, the result is 2. High 0s.
    Binary calculation:
    Binary 8: 1000
    moved to the right two: 2 is the 0010, can be simply understood as the number of the number of right shift is small, corresponding to 8 divided by 2 ^ 2 = 2.
    Right-shift operator calculation rule: The number to the left according to the number to the right of the right few.
  3. ">>>" operator denotes an unsigned right shift. High bit 0
    for example, 8 8 >>> 2 shows a right shift two, the result is 2. This may be understood in conjunction with right-shift operator.

Guess you like

Origin www.cnblogs.com/jasonboren/p/11117370.html