很早就学到了,补码取负数的运算可以用 取反 加一 来算但一直不知道为什么。
终于找到一个牛逼的证明
A well-known technique for performing two’s complement negation at the bit level is to complement the
bits and then increment the result. In C, this can be written as ˜x + 1. To justify the correctness of this
technique, observe that for any single bit xi, we have ˜xi = 1 - xi. Let ~x be a bit vector of length w
and x := B2Tw(~x) be the two’s complement number it represents. By Equation 2.2, the complemented bit
vector ˜~x has numeric value