File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes 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 "operator >>> " Watch "operator >>> " New topic

operator >>>

Shashank D

Joined: Jun 21, 2002
Posts: 1
Here is the expression

int m = -3;
m = m >>> 32;

What will be the value of m and why... please explain your answer.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Shashank D:
What will be the value of m and why... please explain your answer.

Shashank D,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name to comply with our unique rule. Thank you.

As for your question - do a search in this forum. This is a common topic of discussion so you'll find lots of threads that have examples of shift operators.

SCJP Tipline, etc.
Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Hi Shashank!
Did you try to compile and run this piece of code?
If yes, what do you think?
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
The value of m should still be -3. Bit shifting an int by 32 to the right is the same as not doing anything to it at all.
The general rule is: bit shifting an int by x times is equivalent to bit shifting by x % 32 (modulo 32).
I agree. Here's the link:
subject: operator >>>
It's not a secret anymore!