Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bitwise shift operations

 
Rowan Chattaway
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone quickly explain to me the behavior of bitwise shift operations.
For example:

13 >> 1 = 6
13 >> 2 = 3
13 >> 3 = 1

I understand the logic in how these bits are shifted and the end result in these cases.
I also understand why if you shift over 3 then you should get 0 back.

However, my question is this: when you bitwise shift 13 to the right by 32, why do you get 13?

13 >> 32 = 13.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try reading through this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic