jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes bitwise operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "bitwise operator" Watch "bitwise operator" New topic
Author

bitwise operator

amit mandal
Ranch Hand

Joined: Aug 13, 2010
Posts: 46

can someone tell me the difference between ">>" and ">>>" with an example? Every time am understanding am getting confused and back to where i started :/


ocpjp 6.0 certified.
Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Amit,

What I know is that when using the >> (right shift) the signal won't be considered when the right shift execution.
But when using >>> the signal will be considered, so regarding your value, a signed value will loose the signal.

Take a look at the code and output below:



outputs:

11111111111111111111111111110110
-------------------------------
a >> 2
decimal value: -3
binary value.: 11111111111111111111111111111101
-------------------------------
a >>> 2
decimal value: 1073741821
binary value.: 111111111111111111111111111101

Adolfo Eloy
Software Developer
OCPJP 6
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3983
    
  18

Make sure to never use the >>> operator on bytes, char and shorts. It is inherently broken for those data types.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
amit mandal
Ranch Hand

Joined: Aug 13, 2010
Posts: 46

Thanks guys i understood
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8898
    
    5
Hi Guys,

Bitwise operators like these are NO LONGER ON THE EXAM !

hth,

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
amit mandal
Ranch Hand

Joined: Aug 13, 2010
Posts: 46

Bert Bates wrote:Hi Guys,

Bitwise operators like these are NO LONGER ON THE EXAM !

hth,

Bert


Yes i knew. I just asked for knowledge's sake ;)
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bitwise operator
 
It's not a secret anymore!