This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.

1. You first check out the precedence of the operators. In this case the ~ has precedence over >>. So this will be executed first. resulting in a binary value of 111111...1111 (32 times 1).

2. Then you get the expression 1111...1111 >> 1 which results in 111...111

3. This means that the value of a will be -1.

PS: The way to convert (~) a value is by taking the binary form, inverting all bits and then adding one to the result.