GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  J2EE  >  Java

 Print  |  
Question:  What is the difference between the >> and >>> operators

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


October 10, 2005 17:33:57 #3
 Sreekanth J2EE Expert  Member Since: October 2005    Total Comments: 1 

RE: What is the difference between the >> and >>> oper...
 

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.

     

 

Back To Question