-1

I was taking a look to java java.lang.Integer class and I noticed much methods with ">" and "<" operators but I don't know what are.

For example the method Integer.signum(int i):

public static int signum(int i) {
    // HD, Section 2-7
    return (i >> 31) | (-i >>> 31);
}

Or Integer.rotateLeft(int i, int distance)

public static int rotateLeft(int i, int distance) {
    return (i << distance) | (i >>> -distance);
}
Frankzt
  • 13
  • 4

3 Answers3

0

These operators perform a bitshift to the number.

>> bithshift right

<< bitshift left

Further information here in the Bitwise Operators: section.

Kesem David
  • 2,135
  • 3
  • 27
  • 46
0

These are bit-shift operators.

More information in this page.

Essentially:

  • << --> Signed left shift
  • >> --> Signed right shift
  • >>> --> Unsigned right shift

See this SO question for elaborations on what bit-shifting operations are, and how they modify numbers.

Community
  • 1
  • 1
Mena
  • 47,782
  • 11
  • 87
  • 106
0

>> is arithmetic shift right, >>> is logical shift right and << shift left.
for more details go to Bitwise and Bit Shift Operators

Abdelhak
  • 8,299
  • 4
  • 22
  • 36