Tuesday 10 July 2012

Complements


Complements are used to simplify subtraction
operations. We do subtraction by adding.
A – B = A+ (-B)
• There are two types:
– The radix complement, called the r’s complement.
– The diminished radix complement, called the (r-1)’s complement.
Diminished Radix Complement:

Given a number N in base r having n digits, the (r-1)’s
complement of N is defined as:
(rn – 1) – N
• Decimal numbers are in base-10.
(r-1) = (10-1) = 9.
• The 9’s complement would be defined as:
(10n – 1) – N
• So, to determine the 9’s complement of 52:
(102 – 1) – 52 = 47
• Another example is to determine the 9’s complement
of 3124:
(104 – 1) – 3124 = 6875
Finding Diminished Radix complement:

The DRC or (r-1)’s complement of decimal number is
obtained by subtracting each digit from 9
• The (r-1)’s complement of octal or hexadecimal
number is obtained by subtracting each digit from 7 or
F, respectively
• The DRC (1’s complement) of a binary number is
obtained by subtracting each digit from 1. It can also
be formed by changing 1’s to 0’s and 0’s to 1’s
DRC for Binary Numbers:

For binary numbers r = 2 and (r-1) = 1. So, the 1’s
complement would be defined as:
(2n – 1) – N
• To determine the 1’s complement of 1000101:
(27 – 1) – 1000101 = 0111010
• To determine the 1’s complement of 11110111101:
(211 – 1) - 11110111101 = 00001000010
• Note that 1’s complement can be done by switching
all 0’s to 1’s and 1’s to 0’s.
r's Complement

• The r’s complement of an n-digit number N in base-r is
defined as:
rn – N - for N ≠ 0
0 -for N = 0
• We may obtain r’s complement by adding 1 to (r-1)’s
complement. Since rn – N = [(rn – 1) – N]+1
• 10’s complement of 3229 is:
104 – 3229 = 6771
• 2’s complement of 101101 is:
26 – 101101 = 010011
• Note that to determine 2’s complement, leave the least
significant 0’s and the first 1 unchanged and then
switch the remaining 1’s to 0’ and 0’s to 1’s.




No comments:

Post a Comment