What is the difference between the >> and >>> operators

The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that havebeen shifted out.

Showing Answers 1 - 4 of 4 Answers

Joseph Reddy

  • Sep 9th, 2005
 

The >> operator causes the bits of the left operand to be shifted to the right, based on the value of the right operand. The bits that fill in the shifted left bits have the value of the leftmost bit (before the shift operation).  
The >>> operator is identical to the >> operator, except that the bits that fill in the shifted left bits have the value of 0. The >>> operator is said to be an unsigned shift because it does not preserve the sign of 
the operand.

kanniappan

  • Oct 2nd, 2005
 

>> : operator once moves the bits towards right. It doesn't move the sign bit.

>>>: operator once moves the bits towards right, the sign bit also will gets moving.

infant

  • Oct 5th, 2005
 

While dealing with (+)ve numbers there is no difference between >>> and >> operators.Both operators shift zeros into the upper bits of a number.

The difference arises when dealing with (-)ve numbers.Since (-)ve numbers,(-)ve numbers have their high order bit set to 1.The >>> (Zero Fill Shift Operator) shifts zeros into all the upper bits,INCLUDING THE HIGH ORDER BIT,Thus making the (-)ve number into a (+)ve number.

Suraj Patil

  • Aug 16th, 2014
 

When you deals with >> operator, only shifting is done by moving count times towards right without any replacement by zero.

but when you deals with >>> operator them like >> this operator but only difference is that moving not actually rightmost bit to left instead of that move zero towards left side.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions