There are two types of complements in a binary number system: the one's complement and the two's complement.
To find the one's complement of a binary number, you simply need to flip all the bits (0 becomes 1 and 1 becomes 0) in the binary number. For example:
Binary number : 11001101 One's complement : 00110010
One usage is to subtract a signed binary number B from another signed binary number A using one's complement, we first take the one's complement of B by inverting all its bits (including the sign bit) to obtain -B. We then add A and -B using binary addition, which is equivalent to subtracting B from A.
In digital arithmetic, one's complement is used in some older systems for subtraction operations. One's complement is not commonly used in modern digital systems because it has some drawbacks, such as the existence of two representations for zero (+0 and -0), and the need to add an extra bit for the sign. The two's complement representation of signed binary numbers is now the most commonly used method in digital systems.
The two's complement of a binary number is used to represent negative numbers. To find the two's complement, you first need to find the one's complement of the binary number, then add 1 to it. For example:
Binary number : 11001101 One's complement : 00110010 Add 1: + 1 ------------------------------ Two's complement : 00110011 ------------------------------
In digital arithmetic, two's complement is used for addition, subtraction, and multiplication operations on both signed and unsigned binary numbers. Two's complement is particularly useful for arithmetic operations because it eliminates the need for separate addition and subtraction circuits by ignoring the sign bit and simplifies the implementation of arithmetic operations.
Note that in both cases of the one's complement and the two's complement, the complement operation does not change the value of the binary number, it just represents the binary number in a different way.