首页 > 代码库 > Two's complement

Two's complement

https://en.wikipedia.org/wiki/Two‘s_complement

The two‘s-complement system has the advantage that the fundamental arithmetic operations of addition, subtraction, and multiplication are identical to those for unsigned binary numbers (as long as the inputs are represented in the same number of bits and any overflow beyond those bits is discarded from the result). This property makes the system both simpler to implement and capable of easily handling higher precision arithmetic. Also, zero has only a single representation, eliminating the subtleties associated with negative zero, which exists in ones‘-complement systems.

Two's complement