jim hardy said:
"Negative numbers exist only in the mind of the programmer."
two's complement is a mental trick that I figured was no longer necessary once I accepted 'negative or positive' is just an arbitrary agreement among programmers..
the system itself is cyclic and predictable.
jim, i think you're perspective is fine. it's cyclical, like an odometer (in fact, the old 6800 and some other 8-bit microprocessors had a base-10 BCD addition function, and to do subtraction, they talked of the "9's complement").
anyway, let's say that [itex]W[/itex] is the word width in bits. for an unsigned [itex]W[/itex]-bit number, the range of possible values is
[tex]0 \le N \le 2^W - 1[/tex]
the biggest unsigned value the [itex]W[/itex]-bit word can handle is [itex]2^W-1[/itex]. and the bit pattern for that biggest value is all 1's (as it has to be for an unsigned number):
[tex]2^W - 1 = \underbrace{ 111 \cdots 11 }_{W}[/tex]
the point of overflow (where it "wraps around" or where this binary "odometer" turns over) is between [itex]2^W-1[/itex] and [itex]0[/itex].
so, as far as addition is concerned, your quote is right:
"Negative numbers exist only in the mind of the programmer."
with this [itex]W[/itex]-bit word, what bit pattern would you have so that if you add 1 to that word you get 0? the answer is [itex]2^W-1[/itex].
so then change the role of that bit pattern
in your mind: what number or value would you have so that if you add 1 to that number you get 0? and that answer is, of course, -1.
so that bit pattern, 111...11, can take the role of -1 because when you add 1 to it, you get 0.
now if -1 was the only negative number you needed, you could just bump the point of overflow from between [itex]2^W-1[/itex] and [itex]0[/itex] to between [itex]2^W-2[/itex] and [itex]-1[/itex] (the latter has the same bit pattern as [itex]2^W-1[/itex]). but we generally think we need more negative numbers than just -1. so, both as a matter of convention, but also as a matter of simplicity, in this circle of [itex]2^W[/itex] bit patterns, they moved the point of overflow from between [itex]2^W-1[/itex] and [itex]0[/itex] (or between 111..11 and 000..00) to between [itex]2^{W-1}-1[/itex] and [itex]-2^{W-1}[/itex] (or between 011..11 and 100..00). the latter is the same bit pattern for [itex]2^{W-1}[/itex] for an unsigned [itex]W[/itex]-bit word. they moved the boundary for where overflow occurs in this circle of bit patterns to exactly the opposite side of the circle. that's all two's-complement is.
now, can you see what the reason that the two's-complement is the same as the simple one's complement with 1 added? the reason is this:
[tex]-N \ = \ (-1 \ - \ N) + 1[/tex]
think about, with how these cyclical two's-complement numbers are derived above, and how the bit pattern of all ones, 111..11, always corresponds to the value -1. then think about what it is like to subtract N from -1. are there any borrow operations between bits? that means that the one's-complement (the same as N, but with all of the bits inverted; 0 becomes 1 and 1 becomes 0) is the same as [itex](-1 \ - \ N)[/itex]. then to get [itex]-N[/itex] all you need to do is add 1.