|
Java™ by example!
|
|
|
What is the difference between the >> and >>> operators?
a >> b will shift the number a by b bits to the right in an unsigned manner. It will always add a zero to the left side to fill up the spot that frees up. a >>> b will shift the number a by b bits to the right in a signed manner. It will add a zero to the left side if a is positive, but add a one if a is negative as to keep it negative. Right shifting by one will divide the number by two. Check out the output of following example program to get the hang of it:
outputs: (modified for readability reasons)
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|