Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
22 views23 pages

Study Material For BEE (Textbook) Part-1

This chapter introduces the concept of digital circuits and number systems, focusing on binary, octal, and hexadecimal systems. It explains how to convert between these systems and perform arithmetic operations, highlighting the importance of digital technology in various applications. Additionally, it discusses floating point representation for large and small numbers in binary format.

Uploaded by

tprikshit353
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
0% found this document useful (0 votes)
22 views23 pages

Study Material For BEE (Textbook) Part-1

This chapter introduces the concept of digital circuits and number systems, focusing on binary, octal, and hexadecimal systems. It explains how to convert between these systems and perform arithmetic operations, highlighting the importance of digital technology in various applications. Additionally, it discusses floating point representation for large and small numbers in binary format.

Uploaded by

tprikshit353
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/ 23

Chapter

Number System and Codes

1.1 INTRODUCTION
The term digital in digital circuits is derived from the way circuits perform operations
by counting digits. Adigital circuit operates with binary numbers, i.e., only in two
states. The output of the circuit is either low (0) or high (1) in a positive logic system.
In general, 0 represents zero volts and 1represents five volts. If the situation is
reverse, it is known as a negative logic system.
In digital systems, as explained above, the data is usually in binary states
(0 and l)and is processed and stored electronically to prevent errors due to noise and
interfering signals. At present, digital technology has progressed remarkably from
vacuum-tube circuits to integrated circuits, microprocessors and microcontrollers.
Digital circuits find applications in computers, telephony, data processing, radar navi
gation, military systems, medical instruments and consumer products. The general
properties of number systems, methods of conversion from one to another, arithmetic
operations, weighted codes, non-weighted codes, error detecting and correcting codes
are discussed in this chapter.
1.2 NUMBER SYSTEM

The decimal number system (0, 1,2, .., 9) is commonly used eventhough there are
many other number systems like binary, octal, hexadecimal, etc. It is possible to ex
press a number in any base or radix X". In the binary system, the base is 2. In general.
any number with radix X, having mdigits to the left and n digits to the right of the
decimal point, can be expressed as:
is a,(Xyt a,mui
tlhc digit in (Xyt..
postuon.t a,(k +a,(Xy", +a6,()'+
Ine coeriicient b,(1)
is termed ?t.+Mostb()"
as the where
Sign1ticant
Digit (MSD)and b. is termed as the Least Significant Digit (LSD).
1.2.1 Binary Numbers
The Binary number system is simple because it consists of only twodigits, i.e. O
and 1.
Just as the decimal system with its ten digits is a base-ten system, the binary system
with its two digits is a base-two system. The position of 0or Iin a binary number
indicates its "weight" within the number. In a binary number, the weight of each sue
cessively higher position to the left is an increasing power of two.
2 Digital Cireuits and Design

For example, in the decimal system,


(198). =|x 10+9x 10' +8 x 10°
Hundreds Tens Units

Positional Weights
Similarly. binary numbers are also represented by positional weights.
For example.
(198),0 = (11000110);
-lx2'+1x2° +0x2 +0x2* +0x2' +Ix2' +0x20
= 128 +
64+0+0+0+4+2+0= 198
In the digital system, each of the binary
agroup of4 and 8 bits are called a nibble and a byte
digits is called a bit and
respectively. The highest
decimal
number that can be represented by n-bits binary number is 2"- I(beginning with
zero). Thus, with an 8-bit binary number, the maximum decimal number that can be
represented is 28- | = 255.
1.2.2 Decimal-Binary Conversion
An easy method of converting a decimal number into a binary number is by
the decimal number by 2 progressively, until the quotient of zero is dividing
obtained. The
binary number is obtained by taking the remainder after each division in the reverse
order. This method is popularly known as the double-dabble method. The
for decimal to binary conversion is described in the following example. procedure

Example I.1 Convert the decimal number 53-625 into an equivalent binary number.
Solution

Step 1 The integer is 53. The fraction is 0 -625.


Step 2 Integer conversion:
Division Generated
remainder
2) 53
2) 26
2) 13 ’0
2) 6
2) 3 ’0
2) 1
2) 0 ’ | ’ MSB
Reading the remainders from bottom to top gives the binary equivalent. Thus,
(53),0 =(110101),.
Number System and Codes 3
Step3 Fractional conversion: If the decimal number is a fraction, its
binary
lent is obtained by multiplying the number continuously by 2, recording a equiva
carry in the
integer position each time. The carries in the forward order give the required
number. binary

Multiplication Generated
1nteger
(0-625 x2 = 125’ 1 ’ MSB
0-250 x 2= 0-50’
0-500 x2= 1·00-> 1
0-000 x 2 = 0.00 ->
Further multiplication by two is not possible since the product is zero. The binary
equivalent is obtained by reading the carry terins from top to bottom. Thus, (0-625))o
is (0:101),. The combined number will give the binary
equivalent as
(53-625)0 =(110101-101)).
Example 1.2 Convert the binary number (101111-1101), intoits decimal equivalent.
Solution Abinary number can be converted into a decimal number by multiplying
the binary numbers l or 0 by their weight and adding the products.
101 111
Lix20 = 1
lx 2 = 2
-lx 22 = 4
-1 x 23 = 8
-0x 24 =
-l x 29 = 32
47

Therefore, (101111) can be written as (47)10


Conversion of (0·l101), is done in a similar manner.
0 1 1 01
Lx2-4 (0-0625
-0x2-3 =0-0000
-1x 2-2 =0-2500
-lx 2- =0-5000
08125
Thus, (0-1101), is equalto (0-8125)ho
Therefore, (101111-1 101), is equal to (47-8125)0

1.2.3 Octal Numbers

The Octal number system uses the digits 0, 1, 2,3,4, 5, 6 and 7, The base or radix of
this system is eight. Each significant position in an octal number has a positiOnal
4 Digital Circuits and Design

weight. The least significant position has aweight of 8", i.e. I; the higher signiticans
positions are given weights in the ascending powers of eight, i.e. 8',8,83
respectively. The octal equivalent of adecimalnumber can be obtained by dividing a
given decimal number by 8 repeatedly, untila quotient of 0is obtained. The procedure
is exactly the same as the double-dabble method explained earlier. The decimal to
octal conversion method is explained in the following example.

Example 1.3 Convert (444- 456)10 to an octal number.


Solution Integer conversion:
Division Generated
remainder
8) 444
8 55 ’ 4
8 6 ’
6
8) 0 ’

Reading the remainders from bottom to top, the decimal number (444)0 is equiva
lent to octal (674):
Fractional conversion:
Multiplication Generated integer
0.456x8= 3-648’ 3
0-648 x8=5·184-’ 5
0-184 x8= l·472 ’
0.472 x 8= 3·776 -’ 3
0-776x8= 6-208 -’ 6

The process is terminated when significant digits are obtained.


Thus, the octal equivalent of (444-456)0 is (674.35136).

The conversion from an octal to decimal number can be done by multiplying cach
significant digit of the octal number by its respective weight and adding the products.
The following example illustrates the conversion from octal to decimal.

Example 1.4 Convert the octal numbers (a) (237)% and (b) (120), to decimals.
Solution (a) (237), = 2x8 +3x8' +7x8
= 2x64+3×8+7x1
=128+24 +7
= (159)0
(b) (120)% = 1x8 +2x8' +0x8°
= lx64 +2x8 +0xI
= 64 +16+0
= (80),0
Number Svstem and Codes 5

1.2.4 Octal-Binary Conversion


Conversion from octal to binary and vice versa can be easily carried out. For obtain
ing the binary equivalent of an octal number, each significant digit in the given num
ber is replaced by its 3-bit binary equivalent. For example,
(376) = 3 7 6
= 011 11| 110
Thus, (376) =(011111110), . For converting abinary number toan octal, the
reverse procedure is used, i.e. starting from the least significant bit, each group of 3
bits is replaced by its decimal equivalents. For example.
(10011010101), = 010 011 010 101
=2 3 2 5
Thus. (10011010101)2 =(2325)8
1.2.5 Hexadecimal Numbers
The Hexadecimal number system has a radix of 16 and uses 16 symbols, namely 0, 1,
2.3.4.5.,6,7,8.9, A, B, C, D, Eand F. The symbols A, B, C, D, Eand Frepresent the
decimals 10, 11, 12, 13. 14 and 15 respectively. Each significant position in an hexa
decimal number has a positional weight. The least significant position has a weight of
16, i.e. 1; the higher significant positions are given weights in the ascending powers
of sixteen, i.e. 16'|6-,16, etc. respectively. The hexadecimal equivalent of adeci
mal number can be obtained bydividing the given decimalnumber by 16 repeatedly.
until aquotient of0 is obtained. The following example illustrates how the hexadeci
mal equivalent of a given decimal is obtained.

Example 1.5 Convert (a) (115)10 and (b) (235),o to hexadecimal numbers.
Solution
(a) Division Remainder
16) 115
16)7 3
16) 0 7
Reading the remainders from bottom to top, the decimal number (1 150 is equiva
lent to the hexadecimal (73)16. The hexadecimal (73)16 can also be represented as
73 H.
(b) Division Remainder
16) 235
16)14 11’B
16) 0 14’ E
Reading the remainders from bottom to top, the decimal number (235)o is equiva
lent to hexadecimal (EB)\6
6 Digiial Circuits and Design

The conversion fròm an hexadecimal to a decimal number can be


multiplying each significant digit of the hexadecimal by its respectivecarried out by
adding the products. This is illustrated in the following example. weight and
Example 1.6 Convert the following hexadecimal numbers into decimal niunmk.
(a) A3BH and (b) 2F3H
Solution

(a) A3BH=(A3B),6 = Ax16* +3x16+Bx16


= 10x16' +3x16 +1lx16º
= 10x 256 +3x16+||x|
= 2560 ++ 48 +1|

= (2619),0
(b) 2F3H =(2F3),, = 2x16* +Fx16' +3x16°
= 2x 256+15x16+3x1
= 512+240+3
= (755),0

1.2.6 Hexadecimal-Binary Conversion


Conversion from hexadecimal to binary and vice versa can be easily carried
arriving at the binary equivalent of a hexadecimal number, each out. For
given number is replaced by its 4-bit binary equivalent. significant digit in the
For example.
(2D5)\6 = 2 D 5
= 0010 1101 0101
Thus,
(2D5)6 =(0010 11010101),. The
ing a binary number to an hexadecimal, i.e. reverse procedure is used for convert
starting from the least significant bit, each
group of 4 bits is replaced by its decimal equivalents.
For example,
(11110110101)) =111 1011 0101
7 B 5
Thus,
(11110110101), =(7B5)\6
1.2.7 Hexadecimal-Octal Conversion

Conversion from
hexadecimal to octal and vice versa is sometimes required. To con
vert a hexadecimal number to octal, the follov. ing
steps can be applied.
() Convert the given hexadecimal
number to its binary
(ii) Form groups of 3bits, starting from the LSB (least equivalent.
(iii) Write the equivalent octal number for each significant digit).
group 3 bits.
of
Number System and Codes 7
For example,
(47)16 =(0100 0111)2
= (01000111))
= (107)%
Thus, 47 in hexadecimal is equivalent to 107 in the
octalnumber system.
To convert an octal number to
hexadecimal, the steps are as follows:
(i) Convert the given octal
number to its binary
(ii) Formn groups of 4 bits, starting from the LSB.equivalent.
(ii)) Write the equivalent
hexadecimal number for each group of 4 bits.
For example,
(32)% =(011 010,2
= (01 1010),
= (1A)6
Thus, 32 in octal is equivalent to lA in the
hexadecimalnumber system.
1.3 FLOATING POINT
OF NUMBERS REPRESENTATION
In the decimal system, very large and very
small numbers are
notation as follows: 4-69x10 and 1-601lx10 Binary expressed in scientific
numbers can also be ex
pressed by the floating point representation. The floating point
number consists of two parts: the first part represents representation of a
a signed, fixed point number
called the mantissa (m); the second part designates the
position of the decimal (or
binary) point and is called the exponent (e). The fixed point
tion or an integer. The number of bits required to mantissa may be a frac
express the exponent and mantissa is
determined by the accuracy desired from the computing system as well as its
ity to handle such numbers. For example, the capabil
sented in floating point as follows:
decimal number + 6132.789 is repre
sign sign
0-6132789 0 04
mantissa exponent
The mantissa has a0 in the leftmost position to
is considered to be a fixed point denote a plus. Here, the mantissa
fraction. This representation is equivalent to the
number expressed as a fraction 10 times by an exponent, that is
Because of this analogy, the mantissa is sometimes called j lClion 0.6132780 1oni.
par.
Consider, for example acompuci that assumes integer representation for the
mantissa and radix 8 for the numbers. Theoctal number + 36.754
floating point representation will look like this: =36754 x 8 in its

sign Sign
0 36754 I03
Imant1ssa exponent
8 Digital Circuits and Design

When this number is represented in aregister in its binary-coded


value of the register becomes 0 011110 111 101 100 and 1 000 011 form, the actua
Most computers and all electronic calculators have a built-in capacity to
floating-point arithmetic operations. perfor
Example 1.7 Determine the number of bits required to represent in
notation the exponent for decimal numbers in the range of 10**0 floating pont
Solution Let n be the required number of bits to represent the number 10 86
2" = 1086
nlog2 = 86
86 86
n= 285.7
log 2 0.3010
Therefore, 10+*% = 2t285.7
The exponent +285 can be represented by a 10-bit
binary word. It has a range of
exponents (+511 to -512).

1.4 ARITHMETIC OPERATION

Arithmetic operations in a computer are done using binary numbers and not decimal
numbers and these take place in its arithmetic unit. The electronic circuit of a binary
adder with suitable shift register can perform all arithmetic operations.
1.4.1 Binary Arithmetic
The arithmeticrules for Addition,Subtraction, Multiplication and Division of binary
numbers are given below:
Addition Substraction Multiplication Division
(i) 0+0 =0 0-0= 0 0 x0= 0 0x1=0
(ii) 0+ | = 1 1-0=1 0x|=0 1x | =1
(i) 1+0= 1 1-|=0 1x0 =0 0 x0 =not allowed
(iv) 1+ |= 10 10-1 =I 1x |= 1 l x0=not allowed
Binary addition Two binary numbers can be added in the same way as two deC
mal numbers are added. The addition is carried out from the least significant bits and
rnrepds to higher significant bits, adding the carry resulting from the previoUs
addition each timt. Cunnider the addition of the binary number 1010 and
1l.
MSB LSB Daaimal
15
|010 10
I100 I 25
The addition carried out above can be explained as follows:
Step I The least significant bits are added, i.e. 0 + |=lwith acarry 0.
Number System and Codes 9
Step 2 The carry in the previous step is added to the next
ie. 1+1+0 =0 with acarry 1. higher significant bits,
Step 3 The carry in the above step is added to the next higher
i.e. 0 + 1+|=0 with a carry 1. significant bits.
Step 4 The preceding carry is added to the most significant bits, i.e.
with a carry 1. |+|+|=1
Thus, the sum is 1 1001. The addition is also shown in the decimal
number system
in order to compare the results.
Binary subtraction Binary subtraction is also carried out in the same way as deci
mal numbers are subtracted. The subtraction is carried out from the least
significant
bits and proceeds to the higher significant bits. When I is subtracted from 0, a l is
borrowed from the immediate higher significant bit. The following problem explains
the steps involved. Suppose that 1001 is subtracted from 1101.
Case 1:

MSB LSB Decimal


110 1 13
100 1 9
010 0 4
The steps are described below.
Step 1 The LSB in the first column are land 1. Hence, the difference is 1-1=0.
Step2 Inthe second column, the subtraction is performed as 0 - 0 = 0.
Step 3 In the third column, the difference is given by l -0=1.
Step 4 In the fourth column (MSB), the difference is given by 1-1=0.
Thus, the difference between the two binary numbers is 0100.
Case 2:

Decimal
1 001
0 11 I 7
0 01 0 2
The steps are described below.
Step I The least significant bits in the first column are landLU-., ne diflerence
is 1 -] =0.
Step 2 In the coeo1d UUmn, it IS not possible to subtract the 1from 0. So. a l has to
be borrowed from the next MSB (3rd bit). But since the 3rd bit is also 0,
.borrowing has to be done from the MSB (4th bit). The borrowing of 1from
the 4th bit (with weight 8) results in I and 10 with weight 4 in the 3rd column
and Oin 4th column as shown above. Now, the subtraction is performed as
10 -|= 1.
Step 3 In the third column, the difference is given by 1- |=0.
10 Digital Circuits and Design

Step 4 Inthe fourth column (MSB), the difference is given by 0 -0 = 0.


Thus, the difference between the two binary numbers is 0010.
Binary multiplication Binary multiplication is much simpler than decimal mulk.
plication. The procedure is same as that of decimal multiplication. The binary mulhi
plication procedure is as follows.
Step 1 The least significant bit of themultiplier is taken. Ifthe multiplier bit is I. the
multiplicant iscopied as such and, if the multiplier bit is0, a0is placed in al
the bit positions.
Step 2 The next higher significant bit of the multiplier is taken and the partial prod.
uct is written with a shift to the left, as in step 1.
Step 3 Step 2is repeated for allother higher significant bits and each time aleft shift
is given.
Step 4 When all the bits in the multiplier have been taken into account, the partial prod
uct terms are added, which give the actual product of the multiplier and the
multiplicant. The following examples illustrate the multiplication procedure.

Example 1.8 Multiply the following binary numbers: (a) 1011 and 1101, (b) 100110
and 1001 and (c) 1·01 and 101.
Solution
(a) 1011xl101
10 1 1

101 1
0 0 0 0
1 0 11
1 0 1 1
0 11 1 1
(b) 100110 x 1001
100 11 0
x 10 0 1
1 00 1 10
0 0 0 0 0 0
00 0 0 0 0
1 0 0 1 1 0
10 1 0 10 1 1 0
(c) 1.01×10.1
1. 0 1
1 0.
1 0 1
10 1
1 1: 0 0 1
Number System and Codes 1
Binary division Division in binary follows the same procedure as division in deci
mal. Division by 0 is meaningless. An example is given below.

Example 1.9 Divide the following: (a) 11001+101 (b) 11101+1100


Solution
(a) 11001+101
101
101)11001
101
0101
101
0000
(b) 11101÷1100
10-01101
1100)11101-00000
1100
10100
1100
10000
1100
010000
1100
0100

1.5 1's AND 2's COMPLEMENTS

Subtraction of a number from another can be accomplished by adding the comple


ment of the subtrahend to the minuend. The exct difference can be obtained with
minor manipulations.
1.5.1 1's Complement Subtraction
Subtraction of binary numbers using the l's complement method allows subtraction
only by addition. The I's complement of abinary number can be obtained by chang
ing all Is to Os and allOs to ls. To subtract a smaller number from alarger number, the
T's complement method is as follows:
(i) Determine the l's complement of the smaller number.
(i) Add this to the larger number.
(iii) Remove the carry and add it to the result. This carry is called end-around
carry.

Example 1.10 Subtract (1010), from (|111), using the l's complement method.
Also subtract using direct method and compare.
12 DigitalCircuits and Design

Solution
Direct subtraction l'sComplement method
-I 0 1 0 I's Complement ’ IIT1(+)
0 10 I
0 1 0 1 Carry ’ I0 10 0
Add Carry
0 10 |
Subtraction of alarger number from a smaller one by the l's complement method
involves the following steps:
(i) Determine the 1's complement of the larger number.
(ii) Add this to the smaller number.
(iii) The answer is the l's complement of the true
There is no carry.
result and is opposite in sign.

Example 1.l1 Subtract (1010), from (1000), using the l's


Also subtract by direct method and compare. complement method.
Solution
Direct subtraction
I's Complement method
1000
-10 10 I's Complement ’ 1000(+)
0101
-00 10
Nocarry is obtained. The answer is the l's 1101
sign, i.e. -0010. complement of 1101 and is opposite in

The l's complement method is particularly useful in


cause subtraction can be accomplished with the help of anarithmetic
adder.
logic circuits be
1.5.2 2's Complement Subtraction
The 2's complement of abinary number can be obtained by
adding I to its I's comple
ment. Subtraction ofa smaller number from a larger one by the 2's complement method
involves following steps:
() Determine the 2's complement of the smaller
number.
(ii) Add this to the larger number.
(iii) Omit the carry (there is always a carry in this
case).
Example 1.12 Subtract (1010), from (|), using the 2's
Subtract bydirect method also and compare. complement metnod
Solution
Direct subtraction
2'sComplement method
-1 0 1 0 2's Complement -’ 110
0 10 1
Carry ’ 10 1 01
Number System and Codes 13

The carry is discarded. Thus, the answer is (0101),.


The 2's complement method for subtraction of a larger number from a smaller
one is as follows:
(i) Determine the 2's complement of the larger number.
(ii) Add the 2's complement to the smaller number.
(ii) There is no carry. The result is in 2's complement form and is negative.
(iv) Toget an answer in true form, take the 2's complement and change the sign.

Example 1.13 Subtract (1010), from (1000), using 2's complement method. Sub
tract by direct method also and compare.
Solution
Direct subtraction 2's Complement method
1 00 0 0 00(+)
-1 0 10 2's Complement 01 1 0
0 01 0 No carry 11 1 0
No carry is obtained. Thus, the difference is negative and the true answer is the
2's complement of (1110),, i.e. (0010), .

Though both l's and 2's complement methods of subtraction seem complex com
pared to the direct method of subtraction, both have distinct advantages when applied
using logic circuits, because they allow subtraction to be done using only addition.
The l's and 2's complements of abinary number can be easily arrived at using logic
circuits; the advantage in 2's complement method is that the end-around-carry opera
tion present in the l's complement method is not involved here.
1.5.3 Signed Binary Number Representation
Binary numbers are represented with a separate sign bit along with the magnitude, as
shown below. For example, in an 8-bit binary number, the MSB is the sign bit and the
remaining 7 bits correspond to magnitude. The magnitude part contains true binary
equivalent of the number for positive numbers, while 2's complement form of the
number for negative numbers. For example, +13, 0, -46 are represented as follows:

Sign Magnitude
+3 0 000 1101

000 0000

-46 010 ||10


It is important to note that the number zero is assigned witht the sign bit 0'.
Therefore, the range of numbers that can be represented using 8-bit binary number 1s
-128 to +127. In general, the range of numbers that can be represented by an n-bit
number is (-2n-!) to (+2"- 1).
14 Digual Circuits and Design

1.5.4 Addition in the 2's Complement System


Addition can be explained with four possible cases: (i) when both the numbers a
positive, (i) when augend is a positive and addend is a negative number, (ii) when
augend is a negative and addend is a positive number, or (iv) when both the numbers
are negative.
Case 1 Two Positive Numbers
Consider the addition of +29 and +19:
+29 0 001 1101 (augend)
+ 19 001 0011 (addend)
011 0000 (sum = 48)
‘ Sign bit
The sign bits of both augend and addend are zero and the sign bit of the sum is 0.
indicating that when the sum is positive they have the same number of bits. This must
always be done in the 2's complement system.
Case 2 Positive augend Number and Negative addend Number
Consider the addition of +39 and-22. Remember that-22 will be in its 2's comple
ment form. Therefore, +22 (00010110] must be converted to -22
[11101010].
+39 010 0111 (augend)
- 22 1 110 1010 (addend)
001 0001 (result = 17)

Carry Sign bit


This carry is omitted and hence the result is 0001 0001.
In this case, the sign bit of addend is 1.Sign bits also
addition; in fact, a carry is generated in the last positionparticipate in the process of
of addition. This carry is
always omitted. Therefore, the final sum is 0001 0001, which is
equivalent to +17.
Case 3 Positive addend Number and Negative augend Number
Consider the addition of-47 and + 29.
- 47 ’ 1 101
+29 ’
0001: (augend)
001 1101 (addend)
1 110 1110 (result = -18)
‘Sign bit
The result has a sign bit of 1,
ment form. The last seven bits 110indicating a negative number. It is in the 2's comple
sum. The true magnitude of the sum1110 actually represent the 2's complement oi u
110 1110: the result is can be found by taking the 2's
10010(+18). Thus, 1110 1110 represents -l8.complement o
Number System and Codes 15

Case 4 Two Negative Numbers


Consider the addition of-32 and44.
-32 1 110 0000 (augend)
-44 1 101 0100 (addend)
1 1 011 0100 (result -76)

Carry Sign bit


The carry is discarded and hence theresult is 10110100
The true magnitude of thesum isthe 2's complement of0|1 0100, i.e. I 1001100
(-76). Thus, the 2's complement addition works in every case. This assumes that the
decimal sum is within -128 to +127 range. Otherwise, we get an overflow.
1.5.5 Subtraction in the 2's Complement System
As in the case of addition, subtraction can also be carried out in
four possible cases. Subtraction by the 2's complement system involves addition.
Case 1 Both the Numbers are Positive
Consider the case where +19 is to be subtracted from +28.
+28 ’ 0001 1100
+19 ’ 0001 0011
To subtract +19 from +28, the computer will send the +19 to a 2's complement
circuit to produce
-19 ’1110 1101
The system will then add +28 and -19 as follows:
+28 ’ 0001 1100
-19 ’ 1110 1101
(Sum = 9) 10000 1001
‘ Omit this carry
Case 2 Positive Number and Smaller Negative Number
Consider that the minuend is +39 and the subtrahend is -21. In the 2's comple
ment system, they appear as
+ 39 00100111
- 21 1110 1011
The computer sends -21 to a 2's complement circuit to produce
+ 21 0001 0101
It then adds +39 and +21 as follows:
+39 0010 0111
+21 0001 0101
(Sum = 60) 0011 1100
16 Digital Circuits and Design
Case 3 Positive Number and Larger Negative Number
Consider that the minuend is +19 and the subtrahend is 43. In the 2's comnla
ment system, they appear as
+ 19 0001 0011
- 43 1101 0101
The computer sends the 2's complement of-43, ie.
+ 43 0010 1011
It then adds +19 and +43 as shown below:
+19 ’ 0001 0011
+ 43 ’ 0010 1011
(Sum = 62) 0011 1110
Case 4 Both the Numbers are Negative
Consider the subtraction of-33from -S7. In the 2's complement representation.,
-57 1100 0111
-33 1101 1111

Taking the 2's complement of -33,


+33 0010 0001
Then add + 33 to -57. We have
-57 1100 0111
+33 0010 0001
(-24) 1110 1000
1.5.6 Arithmetic Overflow

When the number of bits in the sum exceeds the number of bits in each of the numbers
added, overflow results. This appears in the ninth significant place, and is also called
the excess-one. Overflow causes a sign change.
Assume that both the input numbers are in the range of-128 to +127. The problem
arises onlywhen the arithmetic circuit adds two positive numbers or two negative num
bers. In such a case, it is possible for the sum to be outside the range of-128 to +127.
Case 1 Two Positive Numbers
Consider the addition of +120 and +65. As the decimal sum of +120 and +65 is
+185, an overflow occurs into the MSD position. This overflow forces the sign bit of
the answer to change.
+120 0111 1000
+ 65 +0100 0001
(185) 1011 1001
As the sign bit is 1, i.e. negative, the answer is not
correct.
Number System and Codes 17

Case 2 Two Negative Numbers


Consider the addition of -77 and -122.
77 10110011
+(-122) ’ +10000110
-199 100111001 ’ 00111001
The 8-bit answer is 0011 1001. Here the sign bit is positive. As the right answer
has to contain a negative sign bit, the answer is not correct.
An overflow is a software problem and not a hardware problem. In digital com
puters, an overflow occurs when an operation results in aquantity beyond the capacity
of the storage register. Therefore, a programmer must check the overflow after each
addition or subtraction by looking for achange in the sign bit. Logic circuitry is used
in each case to detect overflow.

1.5.7 Comparison Between 1's and 2's


Complements
(i) The l's complement can be easily obtained using an inverter. The 2's comple
ment has to be arrived at by first obtaining the 1's complement and then
adding one (1) to it.
(ii) The advantage in the 2's complement system is that only one arithmeticop
eration is required; the l's complement requires two operations.
(iii) While the l's complement is often used in logical manipulations for inver
sion operation, the 2's complement is used only for arithnmetic applications.
1.6 9's COMPLEMENT
in the
The 9's complement ofa decimal number can be found by subtracting each digit
shown-below:
number from 9. The 9's complement of decimal digits 0 to 9 is
Decimaldigit 9's complement
0
1
2
3 6
4
4
5
6 3
2

Example 1.14 Find the 9's complement of each of the following decimal numbers:
(a) 19 (b) 146 (c) 469 and (d) 4397
Solution Subtract each digit in the number from 9 to get the 9's complement.
18 Digital Circuits and Design

(a) 99
19
80 -’ 9's Complement of 19
(b) 999
146
853 ’ 9's Complement of 146
(c) 999
469
530 ’ 9's Complement of 469
(d) 9999
- 4397
5602 ’ 9's Complement of 4397
1.6.1 9's Complement Subtraction
Subtraction of a smaller decimal number from a
system is done by the addition of the 9's complementlarger one in the 9's complement
of the subtrahend to the minuend
and then adding the carry to the result. Subtraction of a
larger
one does not produce a carry, and the result is a negative in thenumber from a smaller
This procedure has a distinct advantage in certain types of 9's complement form.
arithmetic logic.
Example 1.15 Perform the following subtractions by using the 9's
(a) 18-06, (b) 39-23, (c) 34-49 and (d) 49-84. complement method:
Solution
(a) Regular subtraction 9's Complement subtraction
18 18
06
+93 -9's Complement of 6
12 -()11
+1 Add carry to result
12
(b) 39 39
-23 +76 49's Complement of 23
16 -(1)15
+1 Add carry to result
16
(c) 34 34
- 49 + 50
-15
+9'sComplement of 49
84

(d) 49
-15 9's Complement of 84
49
84
+ 15 +9'sComplement of 84
-35 64

-35 9's Complement of 64


Number Svstem and Codes 19
1.7 10's COMPLEMENT
The 10's complement of adecimal number is equal to
its 9's complement +1.
Example 1.16 Convert the following decimal numbers into its 10's complement
form: (a)9, (b) 46 and (c) 739.
Solution
(a)

0- 9's
+1
Complement of 9
l+ 10'sComplement of 9
(b) 99
46
53 4- 9'sComplement of 46
+1
54 - 10' s Complement of 46
(c) 999
739
260 9's Complement of 739
+1
261 10's Complement of 739
1.7.1 10's Complement Subtraction
In the 10's complement method of
subtraction,the minuend is added to the 10's comple
ment of the subtrahend and the carry is dropped.

Example 1.17 Subtract the following decimal numbers using the


method: 10's complement
(a) 9-4, (b)24-09, (c) 69-32 and (d) 347-265.
Solution
(a) Regular subtraction 10's Complement subtraction
9
4
+6 + 10'sComplement of 4
5
()5 Drop carry
(b) 24 24
09
15 +91 + 10's Complement of9
()IS Drop carry
(c) 69 69
-32 + 68
37 + 10's Complement of 32
(1)37 Drop carry
(d) 347
347
265
+735 + 10's Complement of 265
82
(1)082 Drop carry
20 Digital Circuits and Design

1.8 BINARY CODED DECIMAL (BCD)


The Binary Coded Decimal (BCD) is acombination of four binary digitsthat represent
decimal numbers. For example. the 8421 code is a type of binary coded decimal It ho
8421 indicate the bin
four bits and represents the decimaldigits 0to 9. The numbers code numbers and+
weights ofthe four bits. The ease of conversion between the 8421
familiar decimal numbers is the main advantage of this code. To express any decimal
number in BCD, each decimaldigit should be replaced by the appropriate four-bit code
0 to 15.
Table 1.1 gives the binary and BCD codes for the decimal numbers
Table 1.1 Decimal numbers, binary eguivalents and BCD
Decimal number Binary number Binary coded decimal
(BCD)
0000 0000
0
0001 0001
2 0010 0010
0011 0011
3
0100 0100
4
0101 0101
0110 0110
6
0111 0111
7
1000 1000
8
1001 1001
1010 0001 0000
10
1011 0001 0001
0001 0010
12 1100
0001 001|
13 1101
1110 0001 0100
14 0001 0101
15 1111

1.8.1 BCD Addition


require arithmetic operations. Addition
BCD is a numerical code. Many applications three operations, namely subtraction,
other
isthe most important of these because the addition. The rule for addition of two
multiplication and division, can be done using
BCD numbers is given below.
binary addition.
()) Add the two numbers using the rules for number.
than 9, it is a valid BCD
(i) Ifa four-bit sum is equal to or less
carry-out of the group is generated,
(iii) If a four-bit sum is greater than 9, or if a four-bit sum in order to skip the
it isan invalid result. Add 6 (0110,) to the
BCD. If a carry results when b IS
Six invalid states and return the code to
added, add the carry to the next four-bit group.

and 0100 and (b) 00011001


Example l.18 Add the following BCD numbers: (a) 1001
and 00010100.
Nmber System and Codes 21
Solution
(a) I00 I
+0 | 0 0
1|0 1 ’Invalid BCD number 9
+0 | | 0 ’ Add 6 +4
000 |0 0 | | Valid BCD number
13,0
(b) 00 0 1 100 1
+0 0 0 1 0 10 0
0 0 | 0 1 10 1’Right group is
invalid 19
+0 1 10 ’ Add 6 +14
0 0 1 1 0 -0 |’Valid BCD number 33,,
3

1.8.2 BCDSubtraction
Metlhod I Table 1.2shows an algorithnm for BCD
ofthe BCD subtrahend is entered into adder 1, and thesubtraction.
The J's complement
istransferred to adder 2, where either a 1010 or 0000 iscomplement (true) of the result
added,
of the total result. Examples of a positive and negative total depending the sign
on
result are given in Table
1.2. Arrows indicate EAC (end-around-carry) or carry to the next
decade.
Table 1.2 Algorithm for BCD subtraction
Decade Signof totalresult
result
(+) EAC=1 ()EAC =0
Transfer true results Transfer 1's complement
of adder| of result of adder 1
0000 added 1010 added
in adder 2 in adder2
C=0 1010added in 0000 added
adder 2 in adder 2
Total Result Positive:

102 10! 100 EAC indicates a (+) total result


835 1000 0011 0101
- 274 1101 1000 101|l's Complement of 001001110100
+561 1 0101 1011 0000

1100 0001 Transfer true output of adder 1


0101 1100 0001,
0000 1010 0000
0101 1 0110 0001
4
5 6 Ignore this carry 1
22 Digital Circuits and Design
Total Result Negative:

102 10! l00


429 0100 0010 1001 No EAC indicates ( total result
-476 l011 1000 1001 1's Complement of 0100 01110110
- 47 1111 1010 -0010
1
1011
0000 0100 1101 Transfer 1l's Complement of adder l outout
0000 0000 1010
0000 0100 1 0111
4
-Ignore this carry

Method II Another method in BCD subtraction is the addition of the 9's comple.
ment of the subtrahend to the minuend.

Example 1.19 Subtract 748 from 983 using 9's complement method.
Solution

9's complement of 748 = 999


-748
251
Direct method

983 983
-748 + 251 + 9's Complement of 748
235 234
+EAC
235

Example 1.20 Subtract the following using 9's complement method:


(a)649-387 and (b)891-786
Solution
(a) 649 649
387 + 612 t- 9's Complement of 387
262 261 lgnore carry
+EAC
262
(b) 891 891
786 +213
105
+ 9's Complement of 786
104
+EAC
105
Number Systenm and Codes 23

Example 1.21 Subtractthe following using the 10's complement method.


(a) 786-427, (b)473-438 and (c) 357-294
Solution

(a) 786 789


- 427 t 573 t- 10's Complement of 427
359 359
4

Ignore carry
(b) 473 473
438 + 562 + 10'sComplement of 438
35 035
Ignore carry
(c) 357 357
- 294 +706 t- 10's Complement of 294
63 063
Ignore carry
Example 1.22 Carry out BCD subtraction for (68)-(61) using 10's complement
method.
Solution

68 68 0110 1000
-61 39 10's Complement of 61 0011 |001
07 I 07 1010 000
Ignore carry 0110 0110 Add 6
| 0000 011|
Ignore carry
1.9 CODES

Code is a symbolic representation of discrete information, which may be present in


the form of numbers, letters or physical quantities. The symbols used are the binary
digits 0 and I which are arranged according to the rules of codes. These codes are
used to communicate information to a digitalcomputer and to retrieve
It. A code is used to enable an operator to feed data into a
messages from
con1puter directly, in the
form of decimal numbers, alphabets and special characters. The
these data into binary codes and after, computation, transforms thecomputer converts
data into its origi
nal format (decimal numbers, alphabets and special
characters).
When numbers, letters, or words are represented by a special group of
this is called encoding, and the group of symbols is called a code. In symbols,
series of dots and dashes represent alphabet, numerals and Morse code, a
special characters.
Codes are broadly classified into five groups, viz. (i) Weighted Binary Codes,(ii)
Non-weighted Codes. (iii)Error-detecting Codes, (iv) Eror-correcting Codes and (v)
Alphanumeric Codes.

You might also like