• Feb 5th 2008, 03:30 PM
SMAlvarez
How do you use "Complement Addition" to subtract binary, hexadecimal, and decimal numbers?
• Feb 5th 2008, 11:14 PM
earboth
Quote:

Originally Posted by SMAlvarez
How do you use "Complement Addition" to subtract binary, hexadecimal, and decimal numbers?

1. You can use this method only if you have a limited number of digits to write a number.

2. You have to use a carry bit for these operations.

3. You have to calculate the compliment of a number first.

Examples:

a) decimal numbers with 4 digits. The first digit is reserved for the sign of the number: 0 = + and and the highest possible digit (here: ) 9 = -

If you want to calculate 0273 - 0086 you first calculate the compliment of 0086 by determining the difference of each digit to highest possible digit (=9). You'll get 9913. Set the carry bit to 1 (indicating that you want to subtract):
Code:

```number:    0273 compl.:    9913 carry:        1 ------------------         (9)0187```
The 9 in brackets is invisible because you have only 4 digits to write the number.

b) binary numbers with 8 digits. Use exactly the same method but note that now the highest possible digit is 1.
If you want to calculate \$\displaystyle 13_{dec} - 7_{dec}\$ that means 00001101 - 00000111 you first calculate the compliment of 00000111 by determining the difference of each digit to highest possible digit (=1). You'll get 11111000. Set the carry bit to 1 (indicating that you want to subtract):
Code:

```number:    00001101 compl.:    11111000 carry:            1 --------------------         (1)00000110```
And \$\displaystyle 110_{bin} = 6_{dec}\$. The 1 in brackets is invisible because you have only 8 digits to write the number.

c) With hexadcimal numbers you only have to consider that you have 16 different digits and that highest possible digit is F. Use exactly the same method as demonstrated above.