This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes what is the difference between >>  and >>> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "what is the difference between >>  and >>> " Watch "what is the difference between >>  and >>> " New topic
Author

what is the difference between >> and >>>

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
i am running a sample program for using bitwise operators





these 2 statements give the same o/p :roll:

then what might be the difference?


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You will only see the difference if you try shifting a negative number.

Remember that the first bit in a negative number is 1.

>> is a right-shift operator that will keep a negative number negative. That is, a 1 will be shifted in.

>>> is an unsigned right-shift operator that will shift a 0 in and not a 1.
 
Don't get me started about those stupid light bulbs.
 
subject: what is the difference between >> and >>>