One’s Complement vs Two’s Complement in Binary
In digital computing, one’s complement and two’s complement are two
distinct mathematical representations used to store signed (positive and
negative) integers in binary. While both systems use the most
significant bit (MSB) as a sign indicator—where 0 denotes
positive and 1 denotes negative—they differ significantly
in how negative values are formed, how zero is represented, their
numerical ranges, and the hardware complexity required to perform basic
arithmetic operations.
Method of Calculation
- One’s Complement: To find the one’s complement of a
binary number, simply invert (flip) every bit. All
0s become1s, and all1s become0s. For example, in an 8-bit system, \(+5\) is00000101, and \(-5\) is11111010. - Two’s Complement: To find the two’s complement,
invert all the bits (as in one’s complement) and then add
1to the least significant bit (LSB). For \(+5\) (00000101), inverting yields11111010, and adding1results in \(-5\) being represented as11111011.
The Problem of Zero
- One’s Complement: Produces two representations for
zero: positive zero (
00000000) and negative zero (11111111). This dual representation wastes a bit pattern and requires special hardware checks for zero comparisons. - Two’s Complement: Has a unique representation for
zero (
00000000). Computing the two’s complement of zero yields zero itself (with an overflow carry that is discarded), eliminating ambiguity.
Arithmetic Operations and Circuitry
- One’s Complement: When adding signed numbers, if an overflow or carry-out occurs at the most significant bit, an “end-around carry” must be performed by adding that carry bit back to the least significant bit. This requires additional hardware cycles and circuitry.
- Two’s Complement: Standard binary addition works directly for both positive and negative numbers. Any carry-out from the most significant bit is simply ignored. This eliminates the need for special subtraction circuitry, allowing the same adder circuit to handle both addition and subtraction.
Representable Range
For an \(n\)-bit binary representation: * One’s Complement Range: \(-(2^{n-1} - 1)\) to \(+(2^{n-1} - 1)\). For an 8-bit byte, the range is \(-127\) to \(+127\). * Two’s Complement Range: \(-2^{n-1}\) to \(+(2^{n-1} - 1)\). For an 8-bit byte, the range is \(-128\) to \(+127\). The elimination of duplicate zero allows two’s complement to represent one additional negative number.
Because of its single representation of zero and simplified arithmetic circuitry, two’s complement is the universal standard used in modern processor architectures.