Hi Shena,
check the following GREAT links:
http://www.javaranch.com/journal/200406/ScjpTipLine-BitShifting.html http://www.javaranch.com/campfire/StoryBits.jsp Plus read the following as well:
Shift and Bitwise operators are used to manipulate data at bit level.
Shift operatorsBitwise operators
>>&
<<^
>>>|
~
Shift operators should be used only with operands of type int or long, though they can also be used with other integral types. Shift operators always return a result of type INT or LONG.
Positive integer0..0 110012
Negative integer1..1 1100-4
Negative integer1..1 1100-4
Signed right-shift1..1 1110-2
unsigned right-shift0..1 11102147483646
Left-shift1..1 1000-8
With the unsigned right-shift operator (>>>
and the left shift operator, the new bits are always set to 0.
The result of ~x will always be the value ((-x) -1)
regards,
Gitesh
[ August 31, 2007: Message edited by: Gitesh Ramchandani ]