Lecture On Complements
Lecture On Complements
Lecture On Complements
Complements
Complements
Complements are used in digital computers for simplifying the subtraction
operation and for logical manipulation. There are two types of complements
for each base-r number system:
(1) the ’s complement and
(2) the ’s complement
When the value of the base of a number system is substituted, the two
types of complements are found of that number system.
Complements
Example
For the decimal number system, the base, , so we have 10’s and 9’s
complements for decimal number system. Similarly, we have 2’s and 1’s
complements for binary number system and so on.
The ’s Complement
Given a positive number in base with an integer part of digits, the ’s
complement of is defined as– for and for . The following numerical
examples will help clarify the definition.
From the definition and examples, it is clear that the 10’s complement of a
decimal number can be formed by leaving all least significant zeros
unchanged, subtracting the first nonzero least significant digit from 10, and
then subtracting all other higher significant digits from 9.
Similarly, the 2’s complement can be formed by leaving all least significant
zeros and the first nonzero digit unchanged, and then replacing 1’s by 0’s
and 0’s by 1’s in all other higher significant digits.
N.B. The ’s complement of a number exists for any base ( greater than but not
equal to 1) and may be obtained from the definition given above.
The ’s Complement
Given a positive number in base with an integer part of digits and a
fraction part of digits, the ’s complement of is defined as . The following
numerical examples will help clarify the definition.
The 9’s complement of number, is
The number of digits in the number is . No fraction part, so .
Complements
From the definition and examples, it is clear that the 9’s complement of
a decimal number is formed simply by subtracting every digit from 9.
Similarly, the 1’s complement of a binary number is formed simply by
changing 1’s into 0’s and 0’s into 1’s.
it follows that the r’s complement can be obtained from the ’s after the
addition of to the least significant digit. For example, the 2’s complement
of 10110100 is obtained from the 1’s complement 01001011 by adding 1
( to give 01001100.
Answer’s complement of
Example-3: Use ’s complement to perform with the given binary
numbers.
( 1010100
+ 0111100
’s complement of end carry 1 0010000
Answer:
(b 1000100
+ 0101100
’s complement of no carry 1110000
Answer’s complement of
Proof of the Procedure
The addition of to the ’s complement of gives. For numbers having an
integer part of digits, is equal to a 1 in the th position (what has been
called the “end carry”). Since both and
Complements
(a) if , or
(b) if .
In case (a) the answer is positive and equal to , which is directly
obtained by discarding the end carry .
In case (b) the answer is negative and equal to . This case is detected
from the absence of an end carry. The answer is obtained by taking a ’s
complement and adding a negative sign in front.
− [ 𝑟 − ( 𝑀 +𝑟 − 𝑁 ) ]=− ( 𝑁 − 𝑀 ) .
𝑛 𝑛
The procedure for subtraction with the ’s complement is exactly the same
as the one used with the ’s complement except for one variation, called
“end-around carry,” as shown below. The subtraction of , both positive
numbers in base , may be calculated in the following manner:
Complements
(a) 72532
+ 96749
’s complement of 1 69281
end-around carry +
1
69282
Answer: 69282
Complements
(b) 03250
+ 27467
’s complement of no carry 30717
Answer’s complement of
( 1010100
+ 0111011
1’s complement of 1 0001111
end-around carry
1
0010000
Answer:
Complements
(b 1000100
+ 0101011
’s complement of no carry 1101111
Answer’s complement of
(a) if , or
(b) if .
In case (a) the answer is positive and equal to , which is obtained by
adding 1 to the least significant digit (end-around carry).
Complements
In case (b) the answer is negative and equal to . This case is detected
from the absence of an end carry. The answer is obtained by taking a
’s complement and adding a negative sign in front.
−[ 𝒓 −𝒓 − ( 𝑴 +𝒓 − 𝒓 − 𝑵 ) ]= − ( 𝑵 − 𝑴 ) .
𝒏 −𝒎 𝒏 −𝒎
Where bits are reserved for the number and one bit for the sign. Thus
total number of bits, .
S
y S S y y
R R y′ y′
S
y′
R t1
R
S R y Y
0 0 0 0
0 0 1 1 t
0 1 0 0 y
0 1 1 0
1 0 0 1 ∆t1 ∆t1
1 0 1 1
y′
1 1 0 d
1 1 1 d ∆t2 ∆t2
SR
00 01 11 10 S
y y
0 d 1
1 1 d 1 y′
R
Y = S + R′ y
SR = 0
S S S y y
y
R R y′ y′
Ck Ck
y′
R Clock input
J K y Y
0 0 0 0 JK
00 01 11 10
0 0 1 1 y
0 1 0 0 0 1 1
0 1 1 0
1 0 0 1
1 1 1
1 0 1 1
1 1 0 1
1 1 1 0
J S y y
K R y′ y′
Ck
Clock
Preset (Pr)
J
y
Ck
y′
K
Preset
Clear (Cr)
J J Pr y y
Clock Ck Ck Cr Pr y
K y′ y′ Enable 1 1 1 Y
K Cr 0 0 1 0
Clear
Preset 0 1 0 1
Clear
Pr
J
y
Ck
y′
K
Master Slave
Cr
Preset Preset
D J Pr D D Pr
y y y y
Ck
y′ y′ Ck y′ y′
K Cr Cr
Clock
Clock
Clear Clear
D
D y Y y 0 1
0 0 0 0 0 1
0 1 0 Y=D
1 0 1 1 0 1
1 1 1
Preset Preset
T J Pr y T T Pr
y y y
Ck
Clock y′ y′ Ck y′ y′
K Cr Cr
Clock
Clear Clear
T y Y T
y 0 1
0 0 0
0 1 1 0 0 1
Y = Ty′ + T′y
1 0 1 1 1 0
1 1 0