Complements are used in digital computers for simplifying the subtraction operation and for logical manipulations. There are two types of complements for each base-r system: (1) the r’s complement and (2) the (r-1)’s complement. When the value of the base is substituted, the two types receive the names 2’s and 1’s complement for binary numbers, or 10’s and 9’s complement for decimal numbers:

The r’s Complement:

Given a positive number N in base r with an integer part of n digits, the r’s complement of N is defined as r^{n}-N for N≠0 and 0 for N=0. The following numerical example will help clarify the definition.

The 10’s complement of (52520)_{10} is 10^{5} – 52520 = 47480.

The number of digits in the number is n = 5.

The 10’s complement of (0.3267)_{10} is 1 – 0.3267 = 0.6733.

No integer part, so 10^{n} = 10^{0} = 1.

The 10’s complement of (25.639)_{10} is 10^{2} – 25.639 = 74.361.

The 2’s complement of (101100)_{2} is (2^{6})_{10} – (101100)_{2} = (1000000 – 101100)_{2} = 010100.

The 2’s complement of (0.0110)_{2} is (1 – 0.0110)_{2} = 0.1010.

The (r – 1)’s Complement:

Given a positive number N in base r with an integer part of n digits and a fraction part of m digits, the (r – 1)’s complement of N is defined as r^{n} – r^{-m} – N. Some numerical examples follow:

The 9’s complement of (52520)_{10} is (10^{5} – 1 – 52520) = 99999 – 52520 = 47479.

No fraction part, so 10^{-m} = 10^{0} = 1.

The 9’s complement of (0.3267)_{10} is (1 – 10^{-4} – 0.3267) = 0.9999 – 0.3267 = 0.6732.

No integer part, so 10^{n} = 10^{0} = 1.

The 9’s complement of (25.639)_{10} is (10^{2} – 10^{-3} – 25.639) = 99.999 – 25.639 = 74.360.

The 1’s complement of (101100)_{2} is (2^{6} – 1)_{10} – (101100)_{2} = (111111 – 101100)_{2} = 010011.

The 1’s complement of (0.0110)_{2} is (1 – 2^{-4})_{10} – (0.0110)_{2} = (0.1111 – 0.0110)_{2} = 0.1001.

goood

ReplyDelete(r-1)'s when N=0

ReplyDelete