楼主给出的这个例子很好地展示出了two's complement的特性,在这种情况下,用two's complement未必就是原数的负数
比如把
1111解释为15,
The two's complement of an N-bit number is defined as the complement with respect to 2^N, in other words the result of subtracting the number from 2^N.
一个N-bit数(这里是4)的two's complement未必是它十进制的负数,它应该对应
2^N-original = 16 - 15 = 1 = ~(1111) + 1 = 1
如果要成为负数,比如至少15是一个byte,也就是
00001111 = 15
~(00001111) + 1 = 11110001 = -15