A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
bitwise shift operations
Joined: Jan 18, 2002
Oct 25, 2004 09:46:00
Can someone quickly explain to me the behavior of bitwise shift operations.
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.
The early bird may get the worm, but the second mouse gets the cheese.........<br /> <br />Sun Certified Programmer for Java 2 Platform<br />Sun Certified Web-Component Developer for J2EE Platform
Joined: Dec 20, 2001
Oct 25, 2004 10:41:00
Try reading through
SCJP Tipline, etc.
I agree. Here's the link:
subject: bitwise shift operations
Help Me Out With Shift Operators...
i don't get shift operators!!!!
Java Sets Project
shifting operators... please help !
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014