100% found this document useful (1 vote)
102 views19 pages

Complements, Binary Arithmetic

Notes from Digital Electronics about complements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
102 views19 pages

Complements, Binary Arithmetic

Notes from Digital Electronics about complements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Complements

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. 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
1. 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.
2. The 10’s complement of (23450)10 is 105 – 23450 = 76550.
3. The number of digits in the number is n = 5.
4. The 10’s complement of (0.3245)10 is 100 – 0.3245 = 0.6755.
5. Since the number of digits in the integer part of the number is n = 0,
we have 100 = 1.
6. 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.
• From the above examples, it is clear that to find the 10’s complement of a
decimal number all of the bits until the first significant 0 is left unchanged
and the first nonzero least-significant digit is subtracted from 10 and the rest
of the higher significant digits are subtracted from 9. With a similar
reasoning, the 2’s complement of a binary number can be obtained by
leaving all of the least significant zeros and the first nonzero digit unchanged,
and then replacing 1’s with 0’s and 0’s with 1’s. Similarly the 8’s complement
of an octal number can be obtained by keeping all the bits until the first
significant 0 is unchanged, and the first non zero least significant digit is
subtracted from 8 and the rest of the higher significant digits are subtracted
from 7. Similarly, the 16’s complement of a hexadecimal number can be
obtained by keeping all the bits until the first significant 0 is unchanged, and
the first nonzero least-significant digit is subtracted from 16 and the rest of
the higher significant digits are subtracted from 15. Since r’s complement is a
general term, r can take any value e.g., r = 11. Then we will have 11’s
complement for r’s complement case and 10’s complement for (r – 1)’s
complement case.


The (r–1)’s Complement
1. 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.
2. The 9’s complement of (23450)10 is 105 – 100 – 23450 = 76549.
Since there is no fraction part, 10–m = 100 = 1.
3. 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.
4. 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.
• From the above examples, it is clear that to find the 9’s
complement of a decimal number each of the digits can
be separately subtracted from 9. The 1’s complement of a
binary number can be obtained by changing 1s into 0s
and 0s into 1s. Similarly, to find the 7’s complement of a
decimal number each of the digits can be separately
subtracted from 7. Again, to find the 15’s complement of
a decimal number each of the digits can be separately
subtracted from 15.
Find out the 11’s and 10’s complement of the number (576)11.

Solution. The number in base is 11. So to find 11’s complement we have to


follow the r’s complement rule and in order to get 10’s complement the
(r – 1)’s complement rule is to be followed.
11’s complement:
rn – N = 113 – 57611
= (1331)10 – (576)11
Now, 57611 = 5 × 112 + 7 × 111 + 6 × 110
= 605 + 77 + 6
= 68810
Therefore, 11’s complement is 133110 – 68810 = 64310
Now, the decimal number has to be changed in the number
system of base 11.
Division Quotient Generated remainder
643/11 58 5
58/11 5 3
5/11 0 5
Hence the 11’s complement number is (535)11.
10’s complement:
rn – r–m – N = 113 – 110 – 57611
= (1331)10 – (1)10 – (576)11
Therefore, 10’s complement is 133110 – 110 – 68810 = 64210

Now, the decimal number has to be changed in the number system of base 11.
Division Quotient Generated remainder
642/11 58 4
58/11 5 3
5/11 0 5

Hence the 10’s complement number is (534)11 .


Binary Arithmetic
• We are very familiar with different
arithmetic operations, viz. addition,
subtraction, multiplication, and division in a
decimal system. Now we want to find out
how those same operations may be
performed in a binary system, where only
two digits, viz. 0 and 1 exist.
Binary Addition
The rules of binary addition are given in Table 1.1.
Augend Addend Sum Carry Result

0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 0 1 10
Binary Subtraction
The rules of binary subtraction are given in Table 1.2.
Minuend Subtrahend Difference Borrow

0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
• Binary subtraction is also carried out in a similar method
to decimal subtraction. The subtraction is carried out
from the LSB and proceeds to the higher significant bits.
When borrow is 1, as in the second row, this is to be
subtracted from the next higher binary bit as it is
performed in decimal subtraction.
• Actually, the subtraction between two numbers can be
performed in three ways, viz.
– the direct method,
– the r’s complement method, and
– the (r – 1)’s complement method.
Subtraction Using the Direct Method

• The direct method of subtraction uses the


concept of borrow. In this method, we
borrow a 1 from a higher significant
position when the minuend digit is smaller
than the corresponding subtrahend digit.
Binary Multiplication
• Binary multiplication is similar to decimal multiplication
but much simpler than that. In a binary system each
partial product is either zero (multiplication by 0) or
exactly the same as the multiplicand
(multiplication by 1).
Multiplicand Multiplier Result

0 0 0
0 1 0
1 0 0
1 1 1
Binary Division
• Binary division follows the same procedure as decimal
division. The rules regarding binary division are listed in
Table 1.4.

Dividend Divisor Result


0 0 Not Allowed
0 1 0
1 0 Not Allowed
1 1 1

You might also like