This week's book giveaway is in the Jobs Discussion forum. We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line! See this thread for details.

Hi all, I have to small problem which I want clear off. I know for any integer the inversion value is (-X)-1, but need some more clarification on this. Say if you want to invert 18 first thing is to write it in the binary format that's; 1001 0010 then you change the 0s into 1s, and vice versa. which produces 0110 1101 but the answer for ~18 is -19, (-18)-1. So could you please explain the situation here, I know I am wrong in the the 2s complement, Thank you very much.

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)

Well, 2's complement, you recall, is formed by taking the complement and then add one. Therefore, simply inverting and NOT adding one will yeild one less than if you had inverted and then added one. This response assumes you know how 2's complement works... if not, let me know. [ November 14, 2004: Message edited by: Nick George ]

I've heard it takes forever to grow a woman from the ground