Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

MBEYA UNIVERSITY OF SCIENCE AND

TECHNOLOGY
COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY
DEPARTMENT OF COMPUTER ENGINEERING

ORDINARY DIPLOMA IN COMPUTER ENGINEERING /


ICT
SECOND YEAR
CS 6205/ IT 6213: DIGITAL ELECTRONICS
COMPLEMENTS
 Complements are used in digital computers for simplifying
the subtraction operation and for logical manipulations.
 There are two types of complements for each number
system of base-r:
 the r’s complement and
 the (r – 1)’s complement.
COMPLEMENTS
• When we deal with a binary system the value of r is 2 and
hence the complements are 2’s and 1’s complements.
• Similarly for a decimal system the value of r is 10 and we get
10’s and 9’s complements.
• With the same logic if the number system is octal we get 8’s
and 7’s complement,
• while it is 16’s and 15’s complements for hexadecimal
system.
The r’s Complement
• If a positive number N is given in base r with an integer part
of n digits, the r’s complement of N is given as rn–N for N ≠ 0
and 0 for N = 0.
• The following examples will clarify the definition.
The 10’s complement of (23450)10 is 105 – 23450 = 76550.
The number of digits in the number is n = 5.
The 10’s complement of (0.3245)10 is 100 – 0.3245 = 0.6755.
Since the number of digits in the integer part of the number is n = 0,
we have 100 = 1.
The 10’s complement of (23.324)10 is 102 – 23.324 = 76.676.
The number of digits in the integer part of the number is n = 2.
Now if we consider a binary system, then r = 2.
The 2’s complement of (10110)2 is
(25)10 – (10110)2 = (100000 – 10110)2 = 01010.

The 2’s complement of (0.1011)2 is


(20)10 – (0.1011)2 = (1 – 0.1011)2 = 0.0101.
Now if we consider an octal system, then r = 8.
The 8’s complement of (2450)8 is
(84)10 – (2450)8 = (409610 – 24508)
= (409610 – 132010)
= 277610.
= 53308.
Now if we consider a hexadecimal system, then r = 16.
The 16’s complement of (4A30)16 is (164)10 – (4A30)16
= (6553610 – 4A3016)
= (6553610 – 1899210)
= 4654410
= B5D016.
The (r–1)’s Complement
• If a positive number N is given in base r with an integer
part of n digits and a fraction part of m digits, then the
(r – 1)’s complement of N is given as (rn – r–m– N) for
N≠0 and 0 for N = 0.
• The following examples will clarify the definition.
The 9’s complement of (23450)10 is 105 – 100 – 23450 = 76549.
Since there is no fraction part, 10–m = 100 = 1.
The 9’s complement of (0.3245)10 is
100 – 10–4 – 0.3245 = 0.6754.
Since there is no integer part, 10n = 100 = 1.
The 9’s complement of (23.324)10 is
102 – 10–3 – 23.324 = 76.675.
Now if we consider a binary system, then r = 2, i.e., (r – 1) = 1.
The 1’s complement of (10110)2 is
(25–1)10 – (10110)2 = 01001.
The 1’s complement of (0.1011)2 is
(1–2–4)10 – (0.1011)2 = 0.0100.
Now if we consider an octal system, then r = 8, i.e., (r – 1) = 7.
The 7’s complement of (2350)8 is
84 – 80 – 23508 = 409510 – 125610
= 283910
= 54278.
The 15’s complement of (A3E4)16 is
164 – 160 – A3E416 = 6553510 – 4195610
= 2357910
= 5C1B16.
Exercise
• Find out the 11’s and 10’s complement of the
number (576)11.

You might also like