Marcus Green's site is good and has a tutorial on bit shift operators:
http://www.jchq.net/tutorial/BitShift.htm Another good set of tips and explanation is at
http://www.geocities.com/velmurugan_p/tips.html a. shift operators allow a programmer to move the bit
pattern of a number to the right or to the left.
b. in actual experience u may never use it but for the exam i think u need to understand it.
c. shifting can be to the left or the right. imagine it like moving red and white blocks sitting on a table. if u start to move the line to the left some of the blocks will fall of the table.
d. rule 1: blocks which fall of the table are lost. Bits that fall off during a shift are lost as well.
e. the reason bits "fall off" is because the the bits (which represent numbers byte, short, char, long etc) are of fixed length. so moving even one bit to the left or to the right will make the bit at the end of the line to fall off.
<<<>>>
f. in case there is a left shift (<<) or an unsigned right shift (>>>) the new bits are set to 0.
g. in case of the signed rt shif (>>) the new bits take the value of the most significant bit (MSB)
e.g 1000 0000 0000 0100 - represents an integer - negative because the MSB is 1
if we shift the above bit pattern 2 places to the right using the >>,
the 2 new bits on the left wil be 1s since the MSB is 1
resulting in the new bit pattern as:
1110 0000 0000 0000 0001
now all u need to know is how to do convert hese numbers in decimal.
----------------------------------------
shifting a bit to the left does double the value.
8421
0000 0001 - decimal 1
0000 0010 - decimal 2 .. this was shifted one bit to the left