0% found this document useful (0 votes)
3K views

BCD Addition & Subtraction

The document discusses binary coded decimal (BCD) addition and subtraction. It explains how decimal numbers are represented using 4-bit BCD codes and how to perform addition and subtraction by converting the decimals to BCD, performing the operation, and correcting any results that exceed the BCD range. Examples are provided of both single and multi-digit BCD addition and subtraction, as well as calculating the 9's complement needed for subtraction.

Uploaded by

Ujwala Bhoga
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views

BCD Addition & Subtraction

The document discusses binary coded decimal (BCD) addition and subtraction. It explains how decimal numbers are represented using 4-bit BCD codes and how to perform addition and subtraction by converting the decimals to BCD, performing the operation, and correcting any results that exceed the BCD range. Examples are provided of both single and multi-digit BCD addition and subtraction, as well as calculating the 9's complement needed for subtraction.

Uploaded by

Ujwala Bhoga
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

BINARY CODED

DECIMAL(BCD)
ADDITION & SUBTRACTION

Mrs. G. Bindu Madhavi(Ph.D)


Assistant Professor
Anurag University

1
Human perception

 We naturally live in a base 10 environment


 Computer exist in a base 2 environment
 So give the computer/digital system the task of doing the
conversions for us.

2
Binary Codes

 “An n-bit binary code is a group of n bits that assume up to 2n distinct


combinations of 1s and 0s, with each combination representing one element
of the set being coded”

 For the 10 digits need a 4 bit code. One code is called Binary Coded
Decimal (BCD)

3
Decimal and BCD

 The BCD is simply the 4 bit representation of


the decimal digit.
 For multiple digit base 10 numbers, each
symbol is represented by its BCD digit
 What happened to 6 digits not used?

4
BCD ADDITION

 Consider the following BCD operation


 Decimal: Add 4 + 1
 Covert to binary 0100
 And 0001
 Getting 0101
 Which is still a BCD representation of a decimal digit

5
Another Example

 A second example
 3 0011
 +3 0011
 Getting 6 or 0 1 1 0
 And in range and a BCD digit representation

6
And now

 Consider 5 + 5
 5 0101
 +5 0101
 giving 1 0 1 0 which is binary 10 but not a BCD digit!
 What to do?
 Try adding 6??
 Why only 6?

7
Adding 6

 Had 1010 and want to add 6 or 0110


 so 1010
 plus 6 0 1 1 0
 Giving 1 0 0 0 0
 Or a carry out to the next binary digit, or if the binary in BCD, the next
BCD digit.

8
Another carry example

 Add 7 + 6
 have 7 0111
 plus 6 0 1 1 0
 Giving 1 1 0 1 and again out of range
 Adding 6 0110
 Giving 1 0 0 1 1 so a 1 carries out to the next BCD digit
 FINAL BCD answer 0001 0011 or 1310

9
Multibit BCD ADDITION

 Add the BCD for 417 to 195


 Would expect to get 612
 BCD setup - start with Least Significant Digit
 0100 0001 0111
 0001 1001 0101
 1100
 Adding 6 0110
 Gives 10010

10
Continuing…..

 Had a carry to the 2nd BCD digit position


 1
 0100 0001 done
 0001 1001 0010
 1011
 Again must add 6 0 1 1 0
 Giving 1 0001
 And another carry

11
Still Continuing ….

 Had a carry to the 3rd BCD digit position


 1
 0100 done done
 0001 0001 0010
 0110
 And answer is 0110 0001 0010 or the BCD for the base 10 number 612

12
BCD SUBTRACTION

 RECAP…..
 we will use 8-4-2-1 bcd
 Decimal numbers > 9 may be obtained when adding two decimal digits
(range: 0-19) i.e. 0 to 9 + 9+1. only 09 have the correct bcd code. • we
need to correct the others
 0 to 9 only legal codes e.g. 19 = 1 9 = 0001 1001 = 11001 thus, for sums
between 10 to 18 must subtract 10 and produce a carry subtract 10 = 1010 2
>> add 2’s complement = 0110

13
BCD SUBTRACTION

 RECALL FOR DECIMAL SUBTRACTION:


 A – B = A + [9’s COMPLEMENT OF B]
 similarly for BCD rules:
 (a) add 9’s comp. of b to a
 (b) If result > 9, correct by adding 0110
 (c)If most significant carry is produced [i.e. =1] then the result is positive
and the end around carry must be added.
 (d) If most significant carry is 0 [i.e. no carry] then the result is negative
and we get the 9’s comp. of the result

14
BCD SUBTRACTION

 9’s complement
 The 9’s complement of a decimal number is found by subtracting each
digit in the number from 9

Decimal Digit 9’s Complement


0 9
1 8
2 7
. .
. .
. .
9 0 15
BCD SUBTRACTION

 E.G. 9’s COMPLEMENT of 28 = 99 –28 = 71


 9’s COMPLEMENT of 562 = 999 –562 = 437
 SUBTRACTION OF A SMALLER DECIMAL NUMBER FROM A
LARGER ONE CAN BE DONE BY ADDING THE 9’s COMPLEMENT
OF THE SMALLER NUMBER TO THE LARGER NUMBER AND
THEN ADDING THE CARRY TO THE RESULT (END AROUND
CARRY).
 WHEN SUBTRACTING A LARGER NUMBER FROM A SMALLER
ONE THERE IS NO CARRY AND THE RESULT IS IN 9’s
COMPLEMENT FORM AND NEGTIVE.

16
BCD SUBTRACTION

 EXAMPLES: (a) +8 +8
 -3 +6 (9’s Complement of 3)
 (1) 4
 +1 END AROUND CARRY
 = 5

17
BCD SUBTRACTION

 87 –39 >>> 87 + [9’s COMP OF 39]


 8 7 =1000 0111
 6 0 =0110 0000
 1110 0111
 invalid 0110
 (1) 0100 0111
 1
 0100 1000
 = 4 8

18
BCD SUBTRACTION

 18 –72 >>> 18 + [27]


 18= 0001 1000
 27= 0010 0111
 0011 1111 NO CARRY NEGATIVE
 1 0110 Correction
 10101
 0100 0101
 4 5 = -54
 OUTPUT IS A NEGATIVE NUMBER >> THE RESULT IS IN 9’s COMP.
FORM

19
ASSIGNMENT

 PERFORM BCD ADDITION


 (i) 23+89
 (ii) 302+157
 PERFORM BCD SUBTRACTION
 (i) 13-67
 (ii) 45-23
 (iii) 678-456
 (iv) 340-675

20
THANK YOU

21

You might also like