In the binary system, a positive number is simply represented as a simple binary number (with the most significant bit as 0). Meanwhile, a negative number needs to be represented using one of the complements: 1’s complement and 2’s complement.
The most significant bit is the sign bit. For the remaining part,
– with 1’s complement, simply invert each digit of the given number.
– with 2’s complement, add 1 to the result of 1’s complement.
2’s complement is widely used, because “inversion and add one” works well for arithmetic operation: https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html
One thought on “2’s complement”