This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

operator >>>

 
Shashank D
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the expression

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

What will be the value of m and why... please explain your answer.
Thanks
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Corey
 
Brian Lugo
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shashank!
Did you try to compile and run this piece of code?
If yes, what do you think?
Brian
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic