Whenever I read about converting an integer to its twos complement representation, I see the algorithm expressed like so:
twoscomplement(x) = ~x + 1
However, I ran into one source that defines it like so:
twoscomplement(x) = ~(x + 111...111)
Where 111...111
is the representation of -1. How can I prove to myself that this second definition is correct? Can I derive it from the first?