File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 145

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: 3378
    
    9
Make sure to never use the >>> operator on bytes, char and shorts. It is inherently broken for those data types.
amit mandal
Ranch Hand

Joined: Aug 13, 2010
Posts: 46

Thanks guys i understood
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8764
    
    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
 
Similar Threads
Word Games
Static Override
design question
Mapraputa Is
are you guys all aquiver?