it's 2's complement
say +1 is 0000_0000_0000_0000_0000_0000_0000_0001 in binary
in 1's complement, then it's simply invert it:
1111_1111_1111_1111_1111_1111_1111_1110
But this kind of negative number has a problem, there're 2 zeros, namely 0 and ffff_ffff in hex.
Therefore, they've invent something called 2's complement.
it's 1's complement + 1, i.e.
-1 in 1's complement + 1, => 0xffff_fffe + 1 = 0xffff_ffff.
What's nice about 2's complement is e.g. 1 + -1 = 0x0000_0001 + 0xffff_ffff = 0!!!! |