Method of Complements - Binary Example

Binary Example

The method of complements is especially useful in binary (radix 2) since the ones' complement is very easily obtained by inverting each bit (changing '0' to '1' and vice versa). And adding 1 to get the two's complement can be done by simulating a carry into the least significant bit. For example:

01100100 (x, equals decimal 100) - 00010110 (y, equals decimal 22)

becomes the sum:

01100100 (x) + 11101001 (ones' complement of y) + 1 (to get the two's complement) ========== 101001110

Dropping the initial "1" gives the answer: 01001110 (equals decimal 78)

Read more about this topic:  Method Of Complements