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

COMPUTER SYSTEM ARCHITECTURE

UNIT – I: Number Systems: Binary, Octal, Hex Decimal, and Conversions, range;
Binary additions and subtractions (using 1c, and 2c), concept of overflow,
representations of negative numbers using 1’s and 2’s complement and range; BCD
numbers: Representation of 8421, 2421, Ex-3, Gray and self-complementary codes;
additions and subtractions on 8421 codes.

NUMBER SYSTEMS:

 A number system relates quantities and symbols. In digital electronics, the number
system is used for representing the information. The number system has different
bases and the most common of them are the decimal, binary, octal, and hexadecimal.

 The base or radix of the number system is the total number of the digit or basic
symbols used in that particular number system. In decimal system the base is 10,
because of use the numbers 0, 1, 2,3,4,5,6,7,8 and 9.

 A digital system can understand positional number system only where there are a few
symbols called digits and these symbols represent different values depending on the
position they occupy in the number.
 A value of each digit in a number can be determined using
 The digit
 The position of the digit in the number
 The base of the number system (where base is defined as the total number of
digits available in the number system).

Types of Number Systems


Some of the important types of number system are
1. Decimal Number System
2. Binary Number System
3. Octal Number System
4. Hexadecimal Number System
These number systems are explained below in details.
1. Decimal Number Systems

 The number system is having digit 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; this number system is


known as a decimal number system because total ten digits are involved. The base of
the decimal number system is 10.
 In decimal number system, the successive positions to the left of the decimal point
represents units, tens, hundreds, thousands and so on.
 Each position represents a specific power of the base (10). For example, the decimal
number 1234 consists of the digit 4 in the units position, 3 in the tens position, 2 in
the hundreds position, and 1 in the thousands position, and its value can be written as
(1×1000) + (2×100) + (3×10) + (4×l)
(1×103) + (2×102) + (3×101) + (4×l00)
1000 + 200 + 30 + 1
1234
2. Binary Number Systems
 The modern computers do not process decimal number; they work with another
number system known as a binary number system which uses only two digits 0 and1.
 The base of binary number system is 2 because it has only two digit 0 and 1.The
digital electronic equipments are works on the binary number system and hence
the decimal number system is converted into binary system.
Characteristics
 Uses two digits, 0 and 1.
 Also called base 2 number system
 Each position in a binary number represents a 0 power of the base (2).
Example: 20
 Last position in a binary number represents an x power of the base (2).
Example: 2x where x represents the last position - 1.
Example
Binary Number: 101012
Calculating Decimal Equivalent −

Step Binary Number Decimal Number

Step 1 101012 ((1 × 24) + (0 × 23) + (1 × 22) + (0 × 21) + (1 × 20))10

Step 2 101012 (16 + 0 + 4 + 0 + 1)10

Step 3 101012 2110

Note: 101012 is normally written as 10101.


3. Octal Numbers System

The octal system has the base of eight as it uses eight digits 0, 1, 2, 3, 4, 5, 6, 7.

Characteristics
 Uses eight digits, 0,1,2,3,4,5,6,7.
 Also called base 8 number system
 Each position in an octal number represents a 0 power of the base (8). Example: 80
 Last position in an octal number represents an x power of the base (8). Example:
8x where x represents the last position - 1.
Example
Octal Number − 125708
Calculating Decimal Equivalent −

Step Octal Number Decimal Number

Step 1 125708 ((1 × 84) + (2 × 83) + (5 × 82) + (7 × 81) + (0 × 80))10

Step 2 125708 (4096 + 1024 + 320 + 56 + 0)10

Step 3 125708 549610

Note: 125708 is normally written as 12570.

4. Hexadecimal Numbers System

 These numbers are used extensively in microprocessor work. The hexadecimal


number system has a base of 16, and hence it consists of the following sixteen number
of digits.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Characteristics
 Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
 Letters represents numbers starting from 10. A = 10, B = 11, C = 12, D = 13, E = 14,
F = 15.
 Also called base 16 number system.
 Each position in a hexadecimal number represents a 0 power of the base (16).
Example 160.
 Last position in a hexadecimal number represents an x power of the base (16).
Example 16x where x represents the last position - 1.

Example −
Hexadecimal Number: 19FDE16
Calculating Decimal Equivalent −

Step Hexadecimal Number Decimal Number

Step 1 19FDE16 ((1 × 164) + (9 × 163) + (F × 162) + (D × 161) + (E × 160))10

Step 2 19FDE16 ((1 × 164) + (9 × 163) + (15 × 162) + (13 × 161) + (14 × 160))10

Step 3 19FDE16 (65536 + 36864 + 3840 + 208 + 14)10


Step 4 19FDE16 10646210

Note − 19FDE16 is normally written as 19FDE.


Comparison of Number System

Number Base Conversion


 In our previous section, we learned different types of number systems such as binary,
decimal, octal, and hexadecimal. In this part of the tutorial, we will learn how we can
change a number from one number system to another number system.
 As, we have four types of number systems so each one can be converted into the
remaining three systems. There are the following conversions possible in Number
System
1. Binary to other Number Systems.
2. Decimal to other Number Systems.
3. Octal to other Number Systems.
4. Hexadecimal to other Number Systems.
Decimal to Other Base System

Step 1 − Divide the decimal number to be converted by the value of the new base.
Step 2 − Get the remainder from Step 1 as the rightmost digit (least significant digit)
of the new base number.
Step 3 − Divide the quotient of the previous divide by the new base.
Step 4 − Record the remainder from Step 3 as the next digit (to the left) of the new
base number.
Repeat Steps 3 and 4, getting remainders from right to left, until the quotient becomes
zero in Step 3. The last remainder thus obtained will be the Most Significant Digit
(MSD) of the new base number.
Example
Decimal Number: 2910
Calculating Binary Equivalent −

Step Operation Result Remainder


Step 1 29 / 2 14 1
Step 2 14 / 2 7 0
Step 3 7/2 3 1
Step 4 3/2 1 1
Step 5 1/2 0 1
As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse order so
that the first remainder becomes the Least Significant Digit (LSD) and the last remainder
becomes the Most Significant Digit (MSD).
Decimal Number : 2910 = Binary Number : 111012.

Other Base System to Decimal System

Step 1 − Determine the column (positional) value of each digit (this depends on the
position of the digit and the base of the number system).
Step 2 − Multiply the obtained column values (in Step 1) by the digits in the
corresponding columns.
Step 3 − Sum the products calculated in Step 2. The total is the equivalent value in
decimal.
Example
Binary Number: 111012
Calculating Decimal Equivalent −

Step Binary Decimal Number


Number
Step 111012 ((1 x 24) + (1 x 23) + (1 x 22) + (0 x 21) + (1 x
1 20))10
Step 111012 (16 + 8 + 4 + 0 + 1)10
2
Step 111012 2910
3

Binary Number : 111012 = Decimal Number : 2910

Other Base System to Non-Decimal System

Step 1 − Convert the original number to a decimal number (base 10).


Step 2 − Convert the decimal number so obtained to the new base number.
Example
Octal Number : 258
Calculating Binary Equivalent −
Step 1 - Convert to Decimal
Step Octal Number Decimal Number
Step 1 258 ((2 x 81) + (5 x 80))10
Step 2 258 (16 + 5)10
Step 3 258 2110

Octal Number : 258 = Decimal Number : 2110


Step 2 - Convert Decimal to Binary
Step Operation Result Remainder
Step 1 21 / 2 10 1
Step 2 10 / 2 5 0
Step 3 5/2 2 1
Step 4 2/2 1 0
Step 5 1/2 0 1

Decimal Number : 2110 = Binary Number : 101012


Octal Number : 258 = Binary Number : 101012

Shortcut Method ─ Binary to Octal

1. In the first step, we have to make the pairs of three bits on both sides of the binary
point. If there will be one or two bits left in a pair of three bits pair, we add the
required number of zeros on extreme sides.
2. In the second step, we write the octal digits corresponding to each pair.

Example
Binary Number : 101012
Calculating Octal Equivalent −

Step Binary Number Octal Number


Step 1 101012 010 101
Step 2 101012 28 58
Step 3 101012 258

Binary Number : 101012 = Octal Number : 258

Shortcut Method ─ Octal to Binary

Step 1 − Convert each octal digit to a 3-digit binary number (the octal digits may be treated
as decimal for this conversion).
Step 2 − Combine all the resulting binary groups (of 3 digits each) into a single binary
number.
Example
Octal Number : 258
Calculating Binary Equivalent −

Step Octal Number Binary Number


Step 1 258 210 510
Step 2 258 0102 1012
Step 3 258 0101012

Octal Number : 258 = Binary Number : 101012

Shortcut Method ─ Binary to Hexadecimal

1. In the first step, we have to make the pairs of four bits on both sides of the binary
point. If there will be one, two, or three bits left in a pair of four bits pair, we add the
required number of zeros on extreme sides.
2. In the second step, we write the hexadecimal digits corresponding to each pair.

Example
Binary Number : 101012
Calculating hexadecimal Equivalent −

Step Binary Number Hexadecimal Number


Step 1 101012 0001 0101
Step 2 101012 110 510
Step 3 101012 1516

Binary Number : 101012 = Hexadecimal Number : 1516

Shortcut Method - Hexadecimal to Binary

Step 1 − Convert each hexadecimal digit to a 4-digit binary number (the hexadecimal digits
may be treated as decimal for this conversion).
Step 2 − Combine all the resulting binary groups (of 4 digits each) into a single binary
number.
Example
Hexadecimal Number : 1516
Calculating Binary Equivalent −

Step Hexadecimal Number Binary Number


Step 1 1516 110 510
Step 2 1516 00012 01012
Step 3 1516 000101012

Hexadecimal Number : 1516 = Binary Number : 101012

Examples: Binary to other Number Systems

Binary to Decimal Conversion

Example 1: (10110.001)2

We multiplied each bit of (10110.001)2 with its respective positional weight, and last we add
the products of all the bits with its weight.

(10110.001)2=(1×24)+(0×23)+(1×22)+(1×21)+(0×20)+
(0×2-1)+(0×2-2)+(1×2-3)
(10110.001)2=(1×16)+(0×8)+(1×4)+(1×2)+(0×1)+
(0×1⁄2)+(0×1⁄4)+(1×1⁄8)
(10110.001)2=16+0+4+2+0+0+0+0.125
(10110.001)2=(22.125 )10

Binary to Octal Conversion

Example 1: (111110101011.0011)2

1. Firstly, we make pairs of three bits on both sides of the binary point.

111 110 101 011.001 1

On the right side of the binary point, the last pair has only one bit. To make it a complete pair
of three bits, we added two zeros on the extreme side.

111 110 101 011.001 100

2. Then, we wrote the octal digits, which correspond to each pair.

(111110101011.0011)2=(7653.14)8

Binary to Hexadecimal Conversion

Example 1: (10110101011.0011)2

1. Firstly, we make pairs of four bits on both sides of the binary point.
111 1010 1011.0011

On the left side of the binary point, the first pair has three bits. To make it a complete pair of
four bits, add one zero on the extreme side.

0111 1010 1011.0011

2. Then, we write the hexadecimal digits, which correspond to each pair.

(011110101011.0011)2=(7AB.3)16

Decimal to other Number System

The decimal number can be an integer or floating-point integer. When the decimal number is
a floating-point integer, then we convert both part (integer and fractional) of the decimal
number in the isolated form(individually). There are the following steps that are used to
convert the decimal number into a similar number of any base 'r'.

1. In the first step, we perform the division operation on integer and successive part with
base 'r'. We will list down all the remainders till the quotient is zero. Then we find
out the remainders in reverse order for getting the integer part of the equivalent
number of base 'r'. In this, the least and most significant digits are denoted by the first
and the last remainders.
2. In the next step, the multiplication operation is done with base 'r' of the fractional and
successive fraction. The carries are noted until the result is zero or when the required
number of the equivalent digit is obtained. For getting the fractional part of the
equivalent number of base 'r', the normal sequence of carrying is considered.

Decimal to Binary Conversion

For converting decimal to binary, there are two steps required to perform, which are as
follows:

1. In the first step, we perform the division operation on the integer and the successive
quotient with the base of binary(2).
2. Next, we perform the multiplication on the integer and the successive quotient with
the base of binary(2).

Example 1: (152.25)10

Step 1:

Divide the number 152 and its successive quotients with base 2.

Operation Quotient Remainder


152/2 76 0 (LSB)

76/2 38 0

38/2 19 0

19/2 9 1

9/2 4 1

4/2 2 0

2/2 1 0

1/2 0 1(MSB)

(152)10=(10011000)2

Step 2:

Now, perform the multiplication of 0.27 and successive fraction with base 2.

Operation Result carry

0.25×2 0.50 0

0.50×2 0 1

(0.25)10=(.01)2

Decimal to Octal Conversion

For converting decimal to octal, there are two steps required to perform, which are as
follows:

1. In the first step, we perform the division operation on the integer and the successive
quotient with the base of octal(8).
2. Next, we perform the multiplication on the integer and the successive quotient with
the base of octal(8).
Example 1: (152.25)10

Step 1:

Divide the number 152 and its successive quotients with base 8.

Operation Quotient Remainder

152/8 19 0

19/8 2 3

2/8 0 2

(152)10=(230)8

Step 2:

Now perform the multiplication of 0.25 and successive fraction with base 8.

Operation Result carry

0.25×8 0 2

(0.25)10=(2)8

So, the octal number of the decimal number 152.25 is 230.2

Decimal to hexadecimal conversion

For converting decimal to hexadecimal, there are two steps required to perform, which are as
follows:

1. In the first step, we perform the division operation on the integer and the successive
quotient with the base of hexadecimal (16).
2. Next, we perform the multiplication on the integer and the successive quotient with
the base of hexadecimal (16).

Example 1: (152.25)10

Step 1:
Divide the number 152 and its successive quotients with base 8.

Operation Quotient Remainder

152/16 9 8

9/16 0 9

(152)10=(98)16

Step 2:

Now perform the multiplication of 0.25 and successive fraction with base 16.

Operation Result carry

0.25×16 0 4

(0.25)10=(4)16

So, the hexadecimal number of the decimal number 152.25 is 230.4.

Octal to other Number System

Octal to Decimal Conversion

The process of converting octal to decimal is the same as binary to decimal. The process
starts from multiplying the digits of octal numbers with its corresponding positional weights.
And lastly, we add all those products.

Let's take an example to understand how the conversion is done from octal to decimal.

Example 1: (152.25)8

Step 1:

We multiply each digit of 152.25 with its respective positional weight, and last we add the
products of all the bits with its weight.

(152.25)8=(1×82)+(5×81)+(2×80)+(2×8-1)+(5×8-2)
(152.25)8=64+40+2+(2×1⁄8)+(5×1⁄64)
(152.25)8=64+40+2+0.25+0.078125
(152.25)8=106.328125
So, the decimal number of the octal number 152.25 is 106.328125

Octal to Binary Conversion

The process of converting octal to binary is the reverse process of binary to octal. We write
the three bits binary code of each octal number digit.

Example 1: (152.25)8

We write the three-bit binary digit for 1, 5, 2, and 5.

(152.25)8=(001101010.010101)2

So, the binary number of the octal number 152.25 is (001101010.010101)2

Octal to hexadecimal conversion

For converting octal to hexadecimal, there are two steps required to perform, which are as
follows:

1. In the first step, we will find the binary equivalent of number 25.
2. Next, we have to make the pairs of four bits on both sides of the binary point. If there
will be one, two, or three bits left in a pair of four bits pair, we add the required
number of zeros on extreme sides and write the hexadecimal digits corresponding to
each pair.

Example 1: (152.25)8

Step 1:

We write the three-bit binary digit for 1, 5, 2, and 5.

(152.25)8=(001101010.010101)2

So, the binary number of the octal number 152.25 is (001101010.010101)2

Step 2:

1. Now, we make pairs of four bits on both sides of the binary point.

0 0110 1010.0101 01

On the left side of the binary point, the first pair has only one digit, and on the right side, the
last pair has only two-digit. To make them complete pairs of four bits, add zeros on extreme
sides.

0000 0110 1010.0101 0100

2. Now, we write the hexadecimal digits, which correspond to each pair.


(0000 0110 1010.0101 0100)2=(6A.54)16

Hexa-decimal to other Number System

Hexa-decimal to Decimal Conversion

The process of converting hexadecimal to decimal is the same as binary to decimal. The
process starts from multiplying the digits of hexadecimal numbers with its corresponding
positional weights. And lastly, we add all those products.

Let's take an example to understand how the conversion is done from hexadecimal to
decimal.

Example 1: (152A.25)16

Step 1:

We multiply each digit of 152A.25 with its respective positional weight, and last we add the
products of all the bits with its weight.

(152A.25)16=(1×163)+(5×162)+(2×161)+(A×160)+(2×16-1)+(5×16-2)
(152A.25)16=(1×4096)+(5×256)+(2×16)+(10×1)+(2×16-1)+(5×16-2)
(152A.25)16=4096+1280+32+10+(2×1⁄16)+(5×1⁄256)
(152A.25)16=5418+0.125+0.125
(152A.25)16=5418.14453125

So, the decimal number of the hexadecimal number 152A.25 is 5418.14453125

Hexadecimal to Binary Conversion

The process of converting hexadecimal to binary is the reverse process of binary to


hexadecimal. We write the four bits binary code of each hexadecimal number digit.

Example 1: (152A.25)16

We write the four-bit binary digit for 1, 5, A, 2, and 5.

(152A.25)16=(0001 0101 0010 1010.0010 0101)2

So, the binary number of the hexadecimal number 152.25 is (1010100101010.00100101)2

Hexadecimal to Octal Conversion

For converting hexadecimal to octal, there are two steps required to perform, which are as
follows:

1. In the first step, we will find the binary equivalent of the hexadecimal number.
2. Next, we have to make the pairs of three bits on both sides of the binary point. If there
will be one or two bits left in a pair of three bits pair, we add the required number of
zeros on extreme sides and write the octal digits corresponding to each pair.

Example 1: (152A.25)16

Step 1:

We write the four-bit binary digit for 1, 5, 2, A, and 5.

(152A.25)16=(0001 0101 0010 1010.0010 0101)2

So, the binary number of hexadecimal number 152A.25 is (0011010101010.010101)2

Step 2:

3. Then, we make pairs of three bits on both sides of the binary point.

001 010 100 101 010.001 001 010

4. Then, we write the octal digit, which corresponds to each pair.

(001010100101010.001001010)2=(12452.112)8

So, the octal number of the hexadecimal number 152A.25 is 12452.112

Binary additions and subtractions (using 1c, and 2c)


Binary arithmetic is essential part of all the digital computers and many other digital system.
Binary Addition
It is a key for binary subtraction, multiplication, division. There are four rules of binary
addition.
In fourth case, a binary addition is creating a sum of (1 + 1 = 10) i.e. 0 is written in the given
column and a carry of 1 over to the next column.

Example − Addition

Binary Subtraction

Subtraction and Borrow, these two words will be used very frequently for the binary
subtraction. There are four rules of binary subtraction.

Example − Subtraction
Binary Multiplication

Binary multiplication is similar to decimal multiplication. It is simpler than decimal


multiplication because only 0s and 1s are involved. There are four rules of binary
multiplication.

Example − Multiplication

Complements
Complements are used in digital computers in order to simply the subtraction operation and
for the logical manipulations. For the Binary number (base-2) system, there are two types of
complements: 1’s complement and 2’s complement.

1’s Complement of a Binary Number

There is a simple algorithm to convert a binary number into 1’s complement. To get 1’s
complement of a binary number, simply invert the given number.
1’s complement of binary number 110010 is 001101

2’s Complement of a Binary Number

There is a simple algorithm to convert a binary number into 2’s complement. To get 2’s
complement of a binary number, simply invert the given number and add 1 to the least
significant bit (LSB) of given result.
2’s complement of binary number 110010 is 001110
Addition and Subtraction using 1's complement

Addition using 1's complement

In binary addition using 1’s complement;

A. Addition of a positive and a negative binary number

We discuss the following cases under this.

Case I: When the positive number has greater magnitude.

In this case addition of numbers is performed after taking 1’s complement of the negative number
and the end-around carry of the sum is added to the least significant bit.

The following examples will illustrate this method in binary addition using 1’s
complement:

1. Find the sum of the following binary numbers:

(i) + 1110 and - 1101

Solution:

+1110 ⇒ 01110

-1101 ⇒ 10010 (taking 1’s complement)

00000

1 carry

00001

Hence the required sum is + 0001.

(ii) + 1101 and - 1011

(Assume that the representation is in a signed 5-bit register).

Solution:

+1101 ⇒ 01101

-1011 ⇒ 10100 (taking 1’s complement)

00001
1 carry

00010

Hence the required sum is + 0010.

Case II: When the negative number has greater magnitude.

In this case the addition is carried in the same way as in case 1 but there will be non end-around
carry. The sum is obtained by taking 1’s complement of the magnitude bits of the result and it will
be negative.

The following examples will illustrate this method in binary addition using 1’s
complement:

Find the sum of the following binary numbers represented in a sign-plus-magnitude 5-


bit register:

(i) + 1010 and - 1100

Solution:

+1010 ⇒ 01010

-1100 ⇒ 10011 (1’s complement)

11101

Hence the required sum is – 0010.

(ii) + 0011 and - 1101.

Solution:

+0011 ⇒ 00011

-1101 ⇒ 10010 (1’s complement)

10101

Hence the required sum is – 1010.

B. When the two numbers are negative

For the addition of two negative numbers 1’s complements of both the numbers are to be taken
and then added. In this case an end-around carry will always appear. This along with a carry from
the MSB (i.e. the 4th bit in the case of sign-plus-magnitude 5-bit register) will generate a 1 in the
sign bit. 1’s complement of the magnitude bits of the result of addition will give the final sum.
The following examples will illustrate this method in binary addition using 1’s
complement:

Find the sum of the following negative numbers represented in a sign-plus-magnitude 5-


bit register:

(i) -1010 and -0101

Solution:

-1010 ⇒ 10101 (1’s complement)

-0101 ⇒ 11010 (1’s complement)

01111

1 carry

10000

1’s complement of the magnitude bits of sum is 1111 and the sign bit is 1.

Hence the required sum is -1111.

(ii) -0110 and -0111.

Solution:

-0110 ⇒ 11001 (1’s complement)

-0111 ⇒ 11000 (1’s complement)

10001

1 carry

10010

1’s complement of 0010 is 1101 and the sign bit is 1.

Hence the required sum is - 1101.

Subtraction using 1's complement

These are the following steps to subtract two binary numbers using 1's complement

o In the first step, find the 1's complement of the subtrahend.


o Next, add the complement number with the minuend.
o If got a carry, add the carry to its LSB. Else take 1's complement of the result which
will be negative
Note: The subtrahend value always get subtracted from minuend.

Example 1: 10101 - 00111

We take 1's complement of subtrahend 00111, which comes out 11000. Now, sum them. So,

10101+11000 =1 01101.

In the above result, we get the carry bit 1, so add this to the LSB of a given result, i.e.,
01101+1=01110, which is the answer.

Example 2: 10101 - 10111

We take 1's complement of subtrahend 10111, which comes out 01000. Now, add both of the
numbers. So,

10101+01000 =11101.

In the above result, we didn't get the carry bit. So calculate the 1's complement of the result,
i.e., 00010, which is the negative number and the final answer.

Evaluate:

(i) 110101 – 100101

Solution:

1’s complement of 10011 is 011010. Hence

Minued - 110101

1’s complement of subtrahend - 011010

Carry over - 1 001111

010000

The required difference is 10000

(ii) 101011 – 111001

Solution:

1’s complement of 111001 is 000110. Hence

Minued - 101011

1’s complement - 000110

110001
Hence the difference is – 1 1 1 0

(iii) 1011.001 – 110.10

Solution:

1’s complement of 0110.100 is 1001.011 Hence

Minued - 1011.001

1’s complement of subtrahend - 1001.011

Carry over - 1 0100.100

0100.101

Hence the required difference is 100.101

(iv) 10110.01 – 11010.10

Solution:

1’s complement of 11010.10 is 00101.01

10110.01

00101.01

11011.10

Hence the required difference is – 00100.01 i.e. – 100.01

Addition and Subtraction using 2's complement

Addition using 2's complement

There are three different cases possible when we add two binary numbers using 2's
complement, which is as follows:

Case 1: Addition of the positive number with a negative number when the positive
number has a greater magnitude.

Initially find the 2's complement of the given negative number. Sum up with the given
positive number. If we get the end-around carry 1 then the number will be a positive number
and the carry bit will be discarded and remaining bits are the final result.

Example: 1101 and -1001


1. First, find the 2's complement of the negative number 1001. So, for finding 2's
complement, change all 0 to 1 and all 1 to 0 or find the 1's complement of the number
1001. The 1's complement of the number 1001 is 0110, and add 1 to the LSB of the
result 0110. So the 2's complement of number 1001 is 0110+1=0111
2. Add both the numbers, i.e., 1101 and 0111;
1101+0111=1 0100
3. By adding both numbers, we get the end-around carry 1. We discard the end-around
carry. So, the addition of both numbers is 0100.

Case 2: Adding of the positive value with a negative value when the negative number
has a higher magnitude.

Initially, add a positive value with the 2's complement value of the negative number. Here, no
end-around carry is found. So, we take the 2's complement of the result to get the final result.

Note: The resultant is a negative value.

Example: 1101 and -1110

1. First, find the 2's complement of the negative number 1110. So, for finding 2's
complement, add 1 to the LSB of its 1's complement value 0001.
0001+1=0010
2. Add both the numbers, i.e., 1101 and 0010;
1101+0010= 1111
3. Find the 2's complement of the result 1110 that is the final result. So, the 2's
complement of the result 1110 is 0001, and add a negative sign before the number so
that we can identify that it is a negative number.

Case 3: Addition of two negative numbers

In this case, first, find the 2's complement of both the negative numbers, and then we will add
both these complement numbers. In this case, we will always get the end-around carry, which
will be added to the LSB, and forgetting the final result, we will take the2's complement of
the result.

Note: The resultant is a negative value.

Example: -1101 and -1110 in five-bit register

1. Firstly find the 2's complement of the negative numbers 01101 and 01110. So, for
finding 2's complement, we add 1 to the LSB of the 1's complement of these numbers.
2's complement of the number 01110 is 10010, and 01101 is 10011.
2. We add both the complement numbers, i.e., 10001 and 10010;
10010+10011= 1 00101
3. By adding both numbers, we get the end-around carry 1. This carry is discarded and
the final result is the 2.s complement of the result 00101. So, the 2's complement of
the result 00101 is 11011, and we add a negative sign before the number so that we
can identify that it is a negative number.

Binary Addition using 2’s Complement

When negative numbers are expressed in binary addition using 2’s complement the addition
of binary numbers becomes easier. This operation is almost similar to that in 1’s complement
system and is explained with examples given below:

A. Addition of a positive number and a negative number.

Case I: When the positive number has a greater magnitude

In this case the carry which will be generated is discarded and the final result is the result
of addition.

The following examples will illustrate this method in binary addition using 2’s
complement:

In a 5-bit register find the sum of the following by using 2’s complement:

(i) +1011 and -0101

Solution:

+1011 ⇒ 01011

-0101 ⇒ 11011 (2’s complement)

(Carry 1 discarded) 00110

Hence the sum is + 0110.

(ii) + 0111 and – 0011.

Solution:

+0111 ⇒ 00111

-0011 ⇒ 11101

(Carry 1 discarded) 00100

Hence the sum is + 0100.

Case II: When the negative number is greater.


When the negative numbers is greater no carry will be generated in the sign bit. The result
of addition will be negative and the final result is obtained by taking 2’s complement of
the magnitude bits of the result.

The following examples will illustrate this method in binary addition using 2’s
complement:

In a 5-bit register find the sum of the following by using 2’s complement:

(i) + 0 0 1 1 and - 0 1 0 1

Solution:

+0011 ⇒ 00011

-0101 ⇒ 11011 (2’s complement)

11110

2’s complement of 1110 is (0001 + 0001) or 0010.

Hence the required sum is - 0010.

(ii) + 0 1 0 0 and - 0 1 1 1

Solution:

+0100 ⇒ 00100

-0111 ⇒ 11001 (2’s complement)

11101

2’s complement of 1101 is 0011.

Hence the required sum is – 0011.

B. When the numbers are negative.

When two negative numbers are added a carry will be generated from the sign bit which
will be discarded. 2’s complement of the magnitude bits of the operation will be the final
sum.
The following examples will illustrate this method in binary addition using 2’s
complement:

In a 5-bit register find the sum of the following by using 2’s complement:

(i) – 0011 and – 0101

Solution:

-0011 ⇒ 11101 (2’s complement)

-0101 ⇒ 11011 (2’s complement)

(Carry 1 discarded) 11000

2’s complement of 1000 is (0111 + 0001) or 1000.

Hence the required sum is – 1000.

(ii) -0111 and – 0010.

Solution:

-0111 ⇒ 11001 (2’s complement)

-0010 ⇒ 11110 (2’s complement)

(Carry 1 discarded) 10111

2’s complement of 0111 is 1001.

Hence the required sum is – 1001.

Subtraction using 2's complement

These are the following steps to subtract two binary numbers using 2's complement

o In the first step, find the 2's complement of the subtrahend.


o Add the complement number with the minuend.
o If we get the carry by adding both the numbers, then we discard this carry and the
result is positive else take 2's complement of the result which will be negative.

Example 1: 10101 - 00111

We take 2's complement of subtrahend 00111, which is 11001. Now, sum them. So,

10101+11001 =1 01110.
In the above result, we get the carry bit 1. So we discard this carry bit and remaining is the
final result and a positive number.

Example 2: 10101 - 10111

We take 2's complement of subtrahend 10111, which comes out 01001. Now, we add both of
the numbers. So,

10101+01001 =11110.

In the above result, we didn't get the carry bit. So calculate the 2's complement of the result,
i.e., 00010. It is the negative number and the final answer.

Evaluate:

(i) 110110 - 10110

Solution:

The numbers of bits in the subtrahend is 5 while that of minuend is 6. We make the number
of bits in the subtrahend equal to that of minuend by taking a `0’ in the sixth place of the
subtrahend.

Now, 2’s complement of 010110 is (101101 + 1) i.e.101010. Adding this with the minuend.

1 10110 Minuend

1 01010 2’s complement of subtrahend

Carry over 1 1 00000 Result of addition

After dropping the carry over we get the result of subtraction to be 100000.

(ii) 10110 – 11010

Solution:

2’s complement of 11010 is (00101 + 1) i.e. 00110. Hence

Minued - 10110

2’s complement of subtrahend - 00110

Result of addition - 11100

As there is no carry over, the result of subtraction is negative and is obtained by writing the
2’s complement of 11100 i.e.(00011 + 1) or 00100.
Hence the difference is – 100.

(iii) 1010.11 – 1001.01

Solution:

2’s complement of 1001.01 is 0110.11. Hence

Minued - 1010.11

2’s complement of subtrahend - 0110.11

Carry over 1 0001.10

After dropping the carry over we get the result of subtraction as 1.10.

(iv) 10100.01 – 11011.10

Solution:

2’s complement of 11011.10 is 00100.10. Hence

Minued - 10100.01

2’s complement of subtrahend - 01100.10

Result of addition - 11000.11

As there is no carry over the result of subtraction is negative and is obtained by writing the
2’s complement of 11000.11.

Hence the required result is – 00111.01.

Concept of Overflow
A CPU with a capacity of 8 bits has a capacity of up to 11111111 in binary. If one more bit
was added there would be an overflow error.
Example: 8-bit overflow
An example of an 8-bit overflow occurs in the binary sum 11111111 + 1 (denary: 255 + 1).
The total is a number bigger than 8 digits, and when this happens the CPU drops the
overflow digit because the computer cannot store it anywhere, and the computer thinks 255
+ 1 = 0.
Overflow errors happen when the largest number that a register can hold is exceeded. The
number of bits that it can handle is called the word size.
Explanation
When two numbers of n digits each are added and the sum occupies n + 1 digits, we say that
an overflow occurred. When the addition is performed with paper and pencil, an overflow is
not a problem since there is no limit to the width of the page to write down the sum.

An overflow is a problem in digital computers because the width of registers is finite. A


result that contains n + 1 bits cannot be accommodated in a register with a standard length of
n bits.

The detection of an overflow after the addition of two binary numbers depends on whether
the numbers are considered to be signed or unsigned.

When two unsigned numbers are added, an overflow is detected from the end carry out of the
most significant position. In the case of signed numbers, the leftmost bit always represents
the sign, and negative numbers are in 2' s complement form. When two signed numbers are
added, the sign bit is treated as part of the number and the end carry does not indicate an
overflow.

An overflow cannot occur after an addition if one number is positive and the other is
negative, since adding a positive number to a negative number produces a result that is
smaller than the larger of the two original numbers.

An overflow may occur if the two numbers added are both positive or both negative. To see
how this can happen, consider the following example. Two signed binary numbers, + 70 and
+ 80, are stored in two 8-bit registers. The range of numbers that each register can
accommodate is from binary + 127 to binary - I28. Since the sum of the two numbers is +
I50, it exceeds the capacity of the 8-bit register. This is true if the numbers are both positive
or both negative.

Representations of negative numbers using 1’s and 2’s complement and


range
1s complement and 2s complement are way of representing the signed binary numbers.
In general, the binary number can be represented in two ways.
1. Unsigned Binary Numbers
2. Signed Binary Numbers
Unsigned Binary Numbers
Using unsigned binary number representation, only positive binary numbers can be
represented. For n-bit unsigned binary numbers, all n-bits are used to represent the magnitude
of the number.
For example, if we represent decimal 12 in 5- bit unsigned number form then (12)10 =
(01100)2. Here all 5 bit are used to represent the magnitude of the number.
In unsigned binary number representation, using n-bits, we can represent the numbers from 0
to 2n – 1. For example, using 4 -bits we can represent the number from 0 to 15 in unsigned
binary number representation.

Signed Binary Numbers


Using signed binary number representation both positive and negative numbers can be
represented.
In signed binary number representation the most significant bit (MSB) of the number is a sign
bit. For positive numbers, the sign bit is 0 and for negative number, the sign bit is 1.
There are three different ways the signed binary numbers can be represented.
1. Signed Magnitude Form
2. 1’s Complement Form
3. 2’s Complement Form

Signed Magnitude Representation


In sign-magnitude representation, the Most Significant bit of the number is a sign bit and the
remaining bit represents the magnitude of the number in a true binary form. For example, if
some signed number is represented in the 8-bit sign-magnitude form then MSB is a sign bit
and the remaining 7 bits represent the magnitude of the number in a true binary form.

Here is the representation of + 34 and -34 in a 8-bit sign-magnitude form.

Since the magnitude of both numbers is the same, the first 7 bits in the representation are the
same for both numbers. For +34, the MSB is 0, and for -34, the MSB or sign bit is 1.
In sign magnitude representations, there are two different representations for 0.
Using n-bits, the range of numbers that can be represented in Sign Magnitude Representation
is from – (2n-1 – 1) to (2n -1 – 1).

1’s Complement Representation


In 1’s complement representation, the representation of the positive number is same as the
negative number. But the representation of the negative number is different.
For example, if we want to represent -34 in 8-bit 1’s complement form, then first write the
positive number (+34). And invert all 1s in that number by 0s and 0s by 1s in that number.
The corresponding inverted number represents the -34 in 1’s complement form. It is also
called 1s complement of the number +34.

Here is another example which shows how to represent -60 in 8-bit 1’s complement form.

Using n-bits, the range of numbers that can be represented in 1’s complement form is from –
(2n-1 – 1) to (2n -1 – 1). For example, using 4-bits, it is possible to represent integers numbers
from -7 to +7 in a 1’s complement form representation.
Similar to sign-magnitude form, there are two different representations of 0 in 1’s
complement form representation.

2’s Complement Representation


In 2’s complement representation also, the representation of the positive number is same
as1’s complement and sign-magnitude form.

But the representation of the negative number is different. For example, if we want to
represent -34 in 2’s complement form then
1. Write the number corresponding to +34.
2. Starting from Least Significant Bit (LSB), just copy all the bits until the first 1 is
encountered in the number.
3. After the first ‘1’ is encountered, invert all the 1s in the number with 0s and 0s in the
number with 1s (including the sign bit)
4. The resultant number is 2’s complement representation of the number -34.
The same is shown below.

The second way of representing -34 in 2’s complement form is


1. Write the number corresponding to +34.
2. Find 1’s complement of +34
3. Add ‘1’ to the 1’s complement number
4. The resultant is 2’s complement representation of -34
The same is shown below.
For n-bit number N, its 2’s complement is (2n – N). For example, the 2’s complement of +34
in 8-bit form is (28 – 34). In binary, it is 100000000 – 00100010 = 11011110. That is a third
way of finding the 2’s complement.
Here is the representation of -60 in sign-magnitude form, 1’s complement, and 2’s
complement form.

Using n-bits, the range of number which can be represented in 2’s complement form is from
– (2n-1 ) to 2n-1 – 1. For example, using 4-bits, it is possible to represent numbers from -8 to
+7. Unlike 1’s complement and sign magnitude form, there is a unique way of representing 0
in this 2’s complement form.

BCD (Binary Coded Decimal) numbers

 BCD code plays an important role in digital circuits. The BCD stands for Binary
Coded Decimal Number.
 Binary-coded decimal is a system of writing numerals that assigns a four-
digit binary code to each digit 0 through 9 in a decimal (base 10) number. Simply put,
binary-coded decimal is a way to convert decimal numbers into their binary
equivalents. However, binary-coded decimal is not the same as simple binary
representation.
 In binary-coded decimal, each digit in a decimal base 10 number is represented as a
group of four binary digits, or bits. Any base 10 number or digit can be represented in
binary notation using binary-coded decimal.

Decimal number = 1764

The binary-coded decimal rendition is represented as the following:

1 7 6 4

0001 0111 0110 0100

There are the following steps to convert the binary number to BCD:

1. First, we will convert the binary number into decimal.


2. We will convert the decimal number into BCD.

Let's take an example to understand the process of converting a binary number into BCD

Example 1: (11110)2

1. First, convert the given binary number into a decimal number.

Binary Number: (11110)2

Finding Decimal Equivalent of the number:

Steps Binary Number Decimal Number

1) (11110)2 ((1 × 24) + (1 × 23) + (1 × 22) + (1 × 21) + (0 × 20))10


2) (11110)2 (16 + 8 + 4 + 2 + 0)10
3) (11110)2 (30)10

Decimal number of the Binary number (11110)2 is (30)10

2. Now, we convert the decimal to the BCD


We convert each digit of the decimal number into groups of the four-bit binary number.

Steps Decimal Number Conversion

Step 1 3010 (0011)2 (0000)2


Step 2 3010 (00110000)BCD

Result:

(11110)2 = (00110000)BCD

Binary Codes
Binary codes are codes which are represented in binary system with modification from the
original one. The group of symbols is called as a code. The digital data is represented, stored
and transmitted as group of binary bits. This group is also called as binary code. The binary
code is represented by the number as well as alphanumeric letter.
Advantages of Binary Code Following is the list of advantages that binary code offers.
o Binary codes are suitable for the computer applications.
o Binary codes are suitable for the digital communications.
o Binary codes make the analysis and designing of digital circuits if we
use the binary codes.
o Since only 0 and 1 are being used, implementation becomes easy.
Binary codes can be classified into two types.
 Weighted codes
 Unweighted codes
If the code has positional weights, then it is said to be weighted code. Otherwise, it is an
unweighted code. Weighted codes can be further classified as positively weighted codes and
negatively weighted codes.
The following table shows the various binary codes for decimal digits 0 to 15.
8 4 2 1 code
 Standard binary coded decimal code is commonly known as a weighted 8421 BCD
code, with 8, 4, 2 and 1 representing the weights of the different bits starting from the
most significant bit (MSB) and proceeding towards the least significant bit (LSB).
The weights of the individual positions of the bits of a BCD code are: 23 = 8, 22 =
4, 21 = 2, 20 = 1. i.e., The weights of this code are 8, 4, 2 and 1.
 This code has all positive weights. So, it is a positively weighted code.
 This code is also called as natural BCD code.
 The main advantage of the Binary Coded Decimal system is that it is a fast and
efficient system to convert the decimal numbers into binary numbers as compared to
the pure binary system.
Example 1: Let us find the BCD equivalent of the decimal number 786.
This number has 3 decimal digits 7, 8 and 6. From the table, we can write the
BCD 8421 codes of 7, 8 and 6 are 0111, 1000 and 0110 respectively.

∴ 78610 =011110000110BCD
There are 12 bits in BCD representation, since each BCD code of decimal digit has 4
bits.
Example 2: Give the BCD equivalent for the decimal number 589.
Solution. The decimal number is 5 8 9 BCD code is 0101 1000 1001
Hence, (589)10 = (010110001001)BCD
Example 3: Give the BCD equivalent for the decimal number 69.27.
Solution. The decimal number 6 9 2 7 BCD code is 0110 1001 0010 0111
Hence, (69.27)10 = (01101001.00100111)BCD

2 4 2 1 code
 The weights of this code are 2, 4, 2 and 1.
 This code has all positive weights. So, it is a positively weighted code.
 It is an unnatural BCD code. Sum of weights of unnatural BCD codes is equal to 9.
 It is a self-complementing code. Self-complementing codes provide the 9’s
complement of a decimal number, just by interchanging 1’s and 0’s in its equivalent
2421 representation.
Example
Let us find the 2421 equivalent of the decimal number 786.
This number has 3 decimal digits 7, 8 and 6.
From the table, we can write the 2421 codes of 7, 8 and 6 are 1101, 1110 and 1100
respectively.
Therefore, the 2421 equivalent of the decimal number 786 is 110111101100.
Excess 3 code
 This code doesn’t have any weights. So, it is an un-weighted code.
 We will get the Excess 3 code of a decimal number by adding three 00110011 to the
binary equivalent of that decimal number. Hence, it is called as Excess 3 code.
 It is a self-complementing code.

Example
Let us find the Excess 3 equivalent of the decimal number 786. This number has 3
decimal digits 7, 8 and 6. From the table, we can write the Excess 3 codes of 7, 8 and
6 are 1010, 1011 and 1001 respectively.
Therefore, the Excess 3 equivalent of the decimal number 786 is 101010111001
Find the excess-3 code of (237.75)10
Solution:
The excess-3 code for (237)10 is obtained by adding 3 to all the digits individually, that is 2, 3
and 7 will become 5, 6 and 10 respectively. These 5, 6 and 10 decimals have to be converted
into binary form and the result is 010101101010.
The excess-3 code for (.75)10 is obtained by replacing 7 and 5 with 10 and 8 respectively by
adding 3 to each digit. That is, the excess-3 code for (.75)10 is .10101000.
Combining the results of the integral and fractional parts, the excess-3 code for (237.75)10 is
010101101010.10101000.

Find the decimal number of excess-3 number 110010100011.01110101.


Solution:
The excess-3 code is 110010100011.01110101
By separating 4 bits as group the equivalent excess-3 code is given as 1100 1010 0011.0111
0101.
Subtracting 0011 from each four-bit group, we obtain the new number as: 1001 0111
0000.0100 0010.
Therefore, the decimal equivalent is (970.42)10.

Gray Code
 This code doesn’t have any weights. So, it is an un-weighted code.
 In the above table, the successive Gray codes are differed in one bit position only.
Hence, this code is called as unit distance code.

Binary code to Gray Code Conversion


o In the Gray code, the MSB will always be the same as the 1'st bit of the given binary
number.
o In order to perform the 2nd bit of the gray code, we perform the exclusive-or (XOR) of
the 1'st and 2nd bit of the binary number. It means that if both the bits are different, the
result will be one else the result will be 0.
o In order to get the 3rd bit of the gray code, we need to perform the exclusive-or (XOR)
of the 2nd and 3rd bit of the binary number. The process remains the same for the
4th bit of the Gray code. Let's take an example to understand these steps.
Example
From the table, we know that the Gray code corresponding to binary code 1000 is 1100.
Now, let us verify it by using the above procedure.
Given, binary code is 1000.
Step 1 − By placing zero to the left of MSB, the binary code will be 01000.
Step 2 − By comparing successive two bits of new binary code, we will get the gray code
as 1100.
Conversion from Gray Code to Binary
Following steps are followed to convert a Gray code to a corresponding binary number.
 The most significant bit (left-most) in the binary code is the same as the
corresponding MSB in the Gray code.
 Add each binary code bit generated to the Gray code bit in the next adjacent position.
Discard carries.

Example: Convert the Grey code 111001 to binary number


Solution:

Self Complementing Codes:


 Self-complementing binary codes are those whose members complement on
themselves. For a binary code to become a self-complementing code, the
following two conditions must be satisfied:

1. The complement of a binary number should be obtained from that number by


replacing 1’s with 0’s and 0’s with 1’s (already stated procedure).
2.The sum of the binary number and its complement should be equal to decimal 9.

 The 2421, the excess‐3 and the 84-2-1 codes are examples of
self‐complementing codes. Such codes have the property that the 9's complement
of a decimal number is obtained directly by changing 1's to 0's and 0's to 1's (i.e.,
by complementing each bit in the pattern).

Example 1: Prove that Xs-3 code is a self-complementing code.

Solution: Consider the Xs-3 number 0101.


 From Table, we obtain 0101 ≡ decimal 2.
 Its complement (by changing 1s to 0s and vice versa) is 1010.
 From Table, we find that decimal equivalent of 1010 is 7.
 Now adding the decimal equivalents of 0101 (≡2) and 1010 (≡7) yields decimal
9.
 It can be seen that all the numbers in Xs-3 code obeys this condition. Then by
condition, Xs-3 code is a self-complementing code.

Example 2: Prove that 2-4-2-1 code is a self-complementing code.


Solution: For example, number 1011 has its equivalent decimal as 5. This is obtained as
follows:
1011 = 1× 2 + 0×4+1× 2 +1= 2 + 2 + 1 = 5
 Now, consider number (1011)2 ≡ (5)10 in Table again. The complement
of 1011 is 0100.
 In 2421 code, the decimal equivalent of 0100 as 4.
 Adding 5 and 4 yields 9.
 Hence, we conclude that the 2-4-2-1 code exhibits the necessary property of self-
complementing codes.

Example 3: Prove that the conventional binary code is not a self-complementing code.
Solution:
 To illustrate this, consider binary number 1011, whose 1’s complement is 0100.
 We know that (1011)2 = (11)10 and (0100)2 = (4)10.
 Now, the sum of (11)10 + (4)10 = (15)10, and not (9)10.
 Therefore, we conclude that 1011 and 0100 are not complementary numbers and
hence, the conventional binary code is not a self-complementing code.

Additions and subtractions on 8421 codes.


BCD Addition
The rules are given below in three steps with an example to make the idea of BCD Addition
clear.
1. At first the given number are to be added using the rule of binary. For example,

2. In second step we have to judge the result of addition. Here two cases are shown to
describe the rules of BCD Addition.
 In case 1 the result of addition of two binary number is greater than 9, which is not
valid for BCD number.
 But the result of addition in case 2 is less than 9, which is valid for BCD numbers.

3. If the four bit result of addition is greater than 9 and if a carry bit is present in the
result then it is invalid and we have to add 6 whose binary equivalent is (0110)2 to the
result of addition. Then the resultant that we would get will be a valid binary coded
number. In case 1 the result was (1111)2, which is greater than 9 so we have to add 6
or (0110)2 to it.

why 6 is being added to the addition result in case BCD Addition instead of any other
numbers.
It is done to skip the six invalid states of binary coded decimal i.e from 10 to 15 and
again return to the BCD codes.

Now the idea of BCD Addition can be cleared from two more examples.
Example:1
Let, 0101 is added with 0110.

Example:2
Now let 0001 0011 is added to 0010 0110.

So no need to add 6 as because both are less than (9)10. This is the process of BCD
Addition.

Example 3: Find the sum of the BCD numbers 01000011 + 00110101

Solution:

Decimal number of the given BCD numbers are as below:

01000011BCD = 4310 and 00110101BCD = 3510

Example 2: Find the sum of the BCD numbers 01110101 + 00110101

Solution:

Decimal number of the given BCD numbers are as below:

01110101BCD = 7510 and 00110101BCD = 3510


Problem : Add (35)10 and (17)10 in 8421 BCD.

BCD Subtraction
There are several methods of BCD Subtraction. BCD subtraction can be done by 1’s
compliment method and 9’s compliment method or 10’s compliment method. Among all
these methods 9’s compliment method or 10’s compliment method is the most easiest. We
will clear our idea on both the methods of BCD Subtraction.

Method of BCD Subtraction : 1


In 1st method we will do BCD Subtraction by 1’s compliment method. There are several
steps for this method shown below. They are:-
1. At first 1’s compliment of the subtrahend is done.
2. Then the complimented subtrahend is added to the other number from which the
subtraction is to be done. This is called adder 1.
3. Now in BCD Subtraction there is a term ‘EAC(end-around-carry)’. If there is a carry
i.e if EAC = 1 the result of the subtraction is +ve and if EAC = 0 then the result is –
ve. A table shown below gives the rules of EAC.
4. In the final result if any carry bit occurs the it will be ignored.
Examples given below would make the idea clear of BCD Subtraction.

Example: – 1
In this example 0010 0001 0110 is subtracted from 0101 0100 0001.
 At first 1’s compliment of the subtrahend is done, which is 1101 1110 1001 and is
added to 0101 0100 0001. This step is called adder 1.
 Now after addition if any carry occurs then it will be added to the next group of
numbers towards MSB. Then EAC will be examined. Here, EAC = 1. So the result of
addition is positive and true result of adder 1 will be transferred to adder 2.
 Now notice from LSB. There are three groups of four bit numbers. 1010 is added
1011 which is the first group of numbers because it do not have any carry. The result
of the addition is the final answer.
 Carry 1 will be ignored as it is from the rule.
 Now move to the next group of numbers. 0000 is added to 0010 and gives the result
0010. It is the final result again.
 Now again move to the next group here 0000 is also added to 0011 to give the final
result 0011.

Therefore,
Now you can check yourself.

We know that 541 − 216 = 325, Thus we can say that our result of BCD Subtraction is
correct.
Example: – 2
In this example let 0101 0001 be subtracted from 0100 1001.
 As per rule firstly 1’s compliment of the subtrahend is done. Then the addition is done
and the result is checked. Here EAC = 0, so the overall result will be –ve.
 Now see the result of adder 1 from LSB. 1’s compliment value of 0111 is transferred
to adder 2 and it is added with 1010 since no carry is added with it as per the rule. The
answer is the final result.
 Now move to the next result of adder 1 i.e 1110. Here 1 is added to it which is the
carry of the previous result. Then it’ value is 1’s complimented i.e 0000 and it is
added to 0000. Result of adder 2 is the final result. This is the final result of BCD
Subtraction.

Method of BCD Subtraction: 2


In 2nd method we will do BCD subtraction in 9’s compliment method.
 Here the method is very simple. At first the decimal equivalent of the given Binary
Coded Decimal (BCD) codes are found out.
 Then the 9’s compliment of the subtrahend is done and then that result is added to the
number from which the subtraction is to be done.
 If there is any carry bit then the carry bit may be added to the result of the subtraction.

Idea may be cleared from an example given below.


Let (0101 0001) − (0010 0001) be the given subtraction.

 As we can see 51 and 21 are the decimal value of the given BCD codes. Then the 9’s
compliment of the subtrahend is done i.e 99 − 21 = 78.
 This complimented value is added with the 51. i.e 51 + 78 = 129.
 The decimal result will be changed into BCD codes to get the result in BCD.
Therefore from the example we can conclude the final result of BCD Subtraction

i.e
BCD subtraction Using 9’s complement
Hint: 9’s complement is found by subtracting each digit in the given decimal number from
9.

Follow the below given procedure to subtract two numbers using 9’s complement.

 When subtracting two BCD numbers(A-B), find the 9’s complement of the negative
decimal number(B).
 Add A+9’s complement of B.
 If carry is generated, add the carry to the result.
 If carry is not generated, find the 9’s complement to get the final result.

Problem : Subtract (56)10 – (32)10 in BCD using 9’s complement.

(56)10 – (32)10 = (24)10


BCD subtraction Using 10’s complement
Hint: 10’s complement can be found by adding 1 with 9’s complement.

Follow the below given procedure to subtract two numbers using 10’s complement.

 When subtracting two BCD numbers(A-B), find the 10’s complement of the negative
decimal number(B).
 Add A+10’s complement of B.
 If carry is generated, the obtained result is positive. Discard the carry to get the result.
 If carry is not generated, the obtained result is negative, find the 10’s complement to
get the final result.

Problem : Subtract (35)10 – (48)10 in BCD using 10’s complement

You might also like