Jay, bit shifting works like this: To shift a number one bit to the right, remove the rightmost bit and add a bit on the left. If the leftmost bit before the shift is 0, add a 0; if it is 1, add a 1.
So looking at your example 32 >> 3:
32 == 0010 0000
Shift this to the right three times, using the method described above. This gives:
0001 0000
0000 1000
0000 0100
So the answer is 0000 0100 == 4.
Note, you always have to take all the bits in the number into account. If your are shifting an
int, which is 32 bits,
you should look at all 32 bits:
0000 0000 0000 0000 0000 0000 0010 0000
[ August 30, 2007: Message edited by: Jesper Young ]