KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Science

What do you understand by 'Shift Operators'? Explain.

Values & Data Types Java

1 Like

Answer

Shift Operators perform bit manipulations on data by shifting the bits of its first operand right or left. The different types of shift operators available in Java are:

  1. Shift Left Operator (<<) Its syntax is op1 << op2. It shifts bits of op1 left by op2 number of bits filling the vacated places on the right with zeros.

  2. Signed Shift Right Operator (>>) Its syntax is op1 >> op2. It shifts bits of op1 right by op2 number of bits filling the vacated places on the left with the value of its Most Significant Bit. It preserves sign bit of the number.

  3. Unsigned Shift Right Operator (>>>) Its syntax is op1 >>> op2. It shifts bits of op1 right by op2 number of bits filling the vacated places on the left with zeros. It doesn't preserve sign bit of the number.

Answered By

1 Like


Related Questions