I am using 2' complement to represent a negative number in binary form
Case 1:number -5
According to the 2' complement technique:
Convert 5 to the binary form:
00000101, then flip the bits
11111010, then add 1
00000001 => result: 11111011
To make sure this is correct, I re-calculate to decimal:
-128 + 64 + 32 + 16 + 8 + 2 + 1 = -5 Case 2: number -240
The same steps are taken:
11110000 00001111 00000001 00010000 => recalculate this I got 16, not -240 I am misunderstanding something?