SlideShare a Scribd company logo
1
Binary Coded Decimal
2
Binary Coded Decimal
Introduction:
Although binary data is the most efficient
storage scheme; every bit pattern represents a
unique, valid value. However, some applications
may not be desirable to work with binary data.
For instance, the internal components of digital
clocks keep track of the time in binary. The
binary value must be converted to decimal
before it can be displayed.
3
Binary Coded Decimal
Because a digital clock is preferable to store the
value as a series of decimal digits, where each
digit is separately represented as its binary
equivalent, the most common format used to
represent decimal data is called binary coded
decimal, or BCD.
4
1. The BCD format
2. Algorithms for addition
3. Algorithms for subtraction
4. Algorithms for multiplication
5. Algorithms for division
Explanation of Binary Coded Decimal
(BCD):
5
1) BCD Numeric Format
Every four bits represent one decimal digit.
 Use decimal values
from 0 to 9
6
 4-bit values above 9 are not used in BCD.
1) BCD Numeric Format
The unused 4-bit values are:
BCD Decimal
1010 10
1011 11
1100 12
1101 13
1110 14
1111 15
7
1) BCD Numeric Format
Multi-digit decimal numbers are stored as
multiple groups of 4 bits per digit.
8
1) BCD Numeric Format
BCD is a signed notation
 positive or negative.
For example, +27 as 0(sign) 0010 0111.
-27 as 1(sign) 0010 0111.
 BCD does not store negative numbers in
two’s complement.
9
1) BCD Numeric Format
Values represented
b3b2b1b0 Sign and magnitude 1’s complement 2’s complement
0111 +7 +7 +7
0110 +6 +6 +6
0101 +5 +5 +5
0100 +4 +4 +4
0011 +3 +3 +3
0010 +2 +2 +2
0001 +1 +1 +1
0000 +0 +0 +0
1000 -0 -7 -8
1001 -1 -6 -7
1010 -2 -5 -6
1011 -3 -4 -5
1100 -4 -3 -4
1101 -5 -2 -3
1110 -6 -1 -2
1111 -7 -0 -1
10
2) Algorithms for Addition
 1100 is not used in BCD.
11
2) Algorithms for Addition
Two errors will occurs in a standard
binary adder.
1) The result is not a valid BCD digit.
2) A valid BCD digit, but not the correct
result.
Solution: You need to add 6 to the result
generated by a binary adder.
12
2) Algorithms for Addition
A simple example of addition in BCD.
0101
+ 1001
1110
+ 0110
1 0100
5
+ 9
Incorrect BCD digit
Add 6
Correct answer
1 4
13
2) Algorithms for Addition
A BCD adder
1001
0101
0001 = 1
0100 = 4
If the result,
S3 S2 S1 S0, is
not a valid
BCD digit,
the multiplexer
causes 6 to be
added to the
result.
14
A simple example of subtraction
3) Algorithms for Subtraction
0111
+ 1101
0100
(+7)
(- 3)
(+4)
0011 is 3, the one’s complement is 1100.
Each of the computations adds 1 to the one’s
complement to produce the two’s complement
of the number.
1100 + 1 = 1101
The two’s complement of 3 is 1101
15
3) Algorithms for Subtraction
The second change has to do with
complements.
 The nine’s complement in BCD, generated
by subtracting the value to be complemented
from another value that has all 9S as its digits.
Adding one to this value produces the ten’s
complement, the negative of the original value.
e.g, the nine’s complement of 631 is
999 – 631 = 368.
368 + 1 = 369 is the ten’s complement
16
 The ten’s complement plays the
subtraction and negation for BCD numbers.
3) Algorithms for Subtraction
Hareware generates the nine’s complement of a single BCD digit.
17
Conclusion for addition and subtraction
Using a BCD adder and Nine’s complement
generation hardware to compute the addition
and the subtraction for signed-magnitude
binary numbers
The algorithm for adding and subtracting
as below:
PM’1: US XS, CU X + Y
PM1: CU X + Y’ + 1, OVERFLOW 0
PM’2: OVERFLOW C
18
The algorithm for adding and subtracting
CZ’PM2: US XS
CZPM2: US 0 C’PM2: US X’S, U U’ + 1
2: FINISH 1
19
Example of addition of BCD numbers
USU = XSX + YSY
XSX = +33 = 0 0011 0011
YSY = +25 = 0 0010 0101
PM’1: US 0, CU 0 0101 1000
PM’2: OVERFLOW 0
Result: USU = 0 0101 1000 = +58
20
Example of subtraction of BCD numbers
USU = XSX + YSY
XSX = +27 = 0 0010 0111
YSY = -13 = 1 0001 0011
PM1: CU 1 0001 0100, OVERFLOW 0
CZ’PM2: US 0
Result: USU = 0 0001 0100 = +14
21
4) Algorithms for Multiplication
1101 Multiplicand M
X 1011 Multiplier Q
1101
1101
0000
1101____
10001111 Product P
22
4) Algorithms for Multiplication
Multiplicand
Multiplier
Product
23
4) Algorithms for Multiplication
Required to use the BCD adder and nine’s
complement circuitry.
In BCD, each digit of the multiplicand may have
any value from 0 to 9; each iteration of the loop
may have to perform up to nine additions. We
must incorporate an inner loop in the algorithm
for these multiple additions.
In addition, use decimal shifts right
operation (dshr), which shift one BCD digit,
or four bits at a time.
24
The BCD multiplication algorithm
1: US XS+YS, VS XS+YS, U 0, i n, Cd 0
ZY0’2: CSU CdU + X, Yd0 Yd0 – 1, GOTO 2
ZY02: i i - 1
3: dshr (CdUV), dshr (Y)
Z’3: GOTO 2
ZT3: US 0, VS 0
Z3: FINISH 1
4) Algorithms for Multiplication
25
4) Algorithms for Multiplication
26
Division can be implemented using either a
restoring or a non-restoring algorithm. An
inner loop to perform multiple subtractions
must be incorporated into the algorithm.
5) Algorithms for Division
10
11 ) 1000
11_
10
27
5) Algorithms for Division
A logic circuit arrangement implements the
restoring-division technique
28
A restoring-division example
Initially 0 0 0 0 0 1 0 0 0
0 0 0 1 1
Shift 0 0 0 0 1 0 0 0
Subtract 1 1 1 0 1
Set q0 1 1 1 1 0
Restore 1 1
0 0 0 0 1 0 0 0 0
Shift 0 0 0 1 0 0 0 0
Subtract 1 1 1 0 1
Set q0 1 1 1 1 1
Restore 1 1
0 0 0 1 0 0 0 0 0
Shift 0 0 1 0 0 0 0 0
Subtract 1 1 1 0 1
Set q0 0 0 0 1 0 0 0 0 1
Shift 0 0 0 1 0 0 0 1
Subtract 1 1 1 0 1
Set q0 1 1 1 1 1
Restore 1 1
0 0 0 1 0 0 0 1 0
remainder
Quotient
First cycle
Second cycle
Third cycle
Fourth cycle
29
5) Algorithms for Division
The restoring-division algorithm:
S1: DO n times
Shift A and Q left one binary position.
Subtract M from A, placing the answer back in A.
If the sign of A is 1, set q0 to 0 and add M back
to A (restore A); otherwise, set q0 to 1.
30
5) Algorithms for Division
The non-restoring division algorithm:
S1: Do n times
If the sign of A is 0, shift A and Q left one
binary position and subtract M from A;
otherwise, shift A and Q left and add M to A.
S2: If the sign of A is 1, add M to A.
31
References:
Computer Systems Organization & Architecture, Addison Wesley
Longman, Inc., 2001
Introduction to Computer Organization 4th Edition. V.Carl
hamacher. 1998
http:// www.sfxavier.ac.uk/computing/bcd/bcd1.htm
http:// www.awl.com/carpinelli

More Related Content

What's hot

Nested loops
Nested loopsNested loops
Nested loops
Neeru Mittal
 
Number system utm notes
Number system utm notesNumber system utm notes
Number system utm notes
Kurenai Ryu
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
student
 
Binary codes
Binary codesBinary codes
Binary codes
GargiKhanna1
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
Ritu Ranjan Shrivastwa
 
Binary number ppt
Binary number pptBinary number ppt
Binary number ppt
Ankit Gupta
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
Mohammad Bashartullah
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complements
arunachalamr16
 
Parallel Adder and Subtractor
Parallel Adder and SubtractorParallel Adder and Subtractor
Parallel Adder and Subtractor
Smit Shah
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital Electronics
Janki Shah
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Piyush Rochwani
 
Bcd
BcdBcd
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
Revathi Subramaniam
 
Digital Logic circuit
Digital Logic circuitDigital Logic circuit
Digital Logic circuit
kavitha muneeshwaran
 
Flip-Flop || Digital Electronics
Flip-Flop || Digital ElectronicsFlip-Flop || Digital Electronics
Flip-Flop || Digital Electronics
Md Sadequl Islam
 
Binary addition.pptx
Binary addition.pptxBinary addition.pptx
Binary addition.pptx
Pooja Dixit
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
SnehalataAgasti
 
binary number system
 binary number system binary number system
binary number system
vishal gupta
 

What's hot (20)

Nested loops
Nested loopsNested loops
Nested loops
 
Number system utm notes
Number system utm notesNumber system utm notes
Number system utm notes
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
 
Binary codes
Binary codesBinary codes
Binary codes
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
Binary number ppt
Binary number pptBinary number ppt
Binary number ppt
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complements
 
Parallel Adder and Subtractor
Parallel Adder and SubtractorParallel Adder and Subtractor
Parallel Adder and Subtractor
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital Electronics
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 
Bcd
BcdBcd
Bcd
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
 
Digital Logic circuit
Digital Logic circuitDigital Logic circuit
Digital Logic circuit
 
Flip-Flop || Digital Electronics
Flip-Flop || Digital ElectronicsFlip-Flop || Digital Electronics
Flip-Flop || Digital Electronics
 
Binary addition.pptx
Binary addition.pptxBinary addition.pptx
Binary addition.pptx
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
 
binary number system
 binary number system binary number system
binary number system
 

Similar to Binary Coded Decimal.pptx

Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
skatiarrahaman
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
100_2_digitalSystem_Chap1 (2).ppt
100_2_digitalSystem_Chap1 (2).ppt100_2_digitalSystem_Chap1 (2).ppt
100_2_digitalSystem_Chap1 (2).ppt
namraashraf56
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
RameshK531901
 
Number system arithmetic
Number system arithmetic Number system arithmetic
Number system arithmetic
renatus katundu
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpuWan Afirah
 
Decimal arithematic operation
Decimal arithematic operationDecimal arithematic operation
Decimal arithematic operationPadmapriyaG
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RabiaAsif31
 
Module 4
Module 4Module 4
Module 4
sadhanakumble
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
amudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
amudhak10
 
Number system
Number systemNumber system
Number system
Mantra VLSI
 
Ch_10.pptx.pdf
Ch_10.pptx.pdfCh_10.pptx.pdf
Ch_10.pptx.pdf
SujanTimalsina5
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
Laguna State Polytechnic University
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
Suganthi Vasanth Raj
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
ssuser52a19e
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RAJKUMARP63
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
MarlonMagtibay2
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
UtkirjonUbaydullaev1
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
Krishnavenimanickam2
 

Similar to Binary Coded Decimal.pptx (20)

Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
100_2_digitalSystem_Chap1 (2).ppt
100_2_digitalSystem_Chap1 (2).ppt100_2_digitalSystem_Chap1 (2).ppt
100_2_digitalSystem_Chap1 (2).ppt
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
 
Number system arithmetic
Number system arithmetic Number system arithmetic
Number system arithmetic
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpu
 
Decimal arithematic operation
Decimal arithematic operationDecimal arithematic operation
Decimal arithematic operation
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Module 4
Module 4Module 4
Module 4
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
Number system
Number systemNumber system
Number system
 
Ch_10.pptx.pdf
Ch_10.pptx.pdfCh_10.pptx.pdf
Ch_10.pptx.pdf
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
 

Recently uploaded

The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 

Recently uploaded (20)

The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 

Binary Coded Decimal.pptx

  • 2. 2 Binary Coded Decimal Introduction: Although binary data is the most efficient storage scheme; every bit pattern represents a unique, valid value. However, some applications may not be desirable to work with binary data. For instance, the internal components of digital clocks keep track of the time in binary. The binary value must be converted to decimal before it can be displayed.
  • 3. 3 Binary Coded Decimal Because a digital clock is preferable to store the value as a series of decimal digits, where each digit is separately represented as its binary equivalent, the most common format used to represent decimal data is called binary coded decimal, or BCD.
  • 4. 4 1. The BCD format 2. Algorithms for addition 3. Algorithms for subtraction 4. Algorithms for multiplication 5. Algorithms for division Explanation of Binary Coded Decimal (BCD):
  • 5. 5 1) BCD Numeric Format Every four bits represent one decimal digit.  Use decimal values from 0 to 9
  • 6. 6  4-bit values above 9 are not used in BCD. 1) BCD Numeric Format The unused 4-bit values are: BCD Decimal 1010 10 1011 11 1100 12 1101 13 1110 14 1111 15
  • 7. 7 1) BCD Numeric Format Multi-digit decimal numbers are stored as multiple groups of 4 bits per digit.
  • 8. 8 1) BCD Numeric Format BCD is a signed notation  positive or negative. For example, +27 as 0(sign) 0010 0111. -27 as 1(sign) 0010 0111.  BCD does not store negative numbers in two’s complement.
  • 9. 9 1) BCD Numeric Format Values represented b3b2b1b0 Sign and magnitude 1’s complement 2’s complement 0111 +7 +7 +7 0110 +6 +6 +6 0101 +5 +5 +5 0100 +4 +4 +4 0011 +3 +3 +3 0010 +2 +2 +2 0001 +1 +1 +1 0000 +0 +0 +0 1000 -0 -7 -8 1001 -1 -6 -7 1010 -2 -5 -6 1011 -3 -4 -5 1100 -4 -3 -4 1101 -5 -2 -3 1110 -6 -1 -2 1111 -7 -0 -1
  • 10. 10 2) Algorithms for Addition  1100 is not used in BCD.
  • 11. 11 2) Algorithms for Addition Two errors will occurs in a standard binary adder. 1) The result is not a valid BCD digit. 2) A valid BCD digit, but not the correct result. Solution: You need to add 6 to the result generated by a binary adder.
  • 12. 12 2) Algorithms for Addition A simple example of addition in BCD. 0101 + 1001 1110 + 0110 1 0100 5 + 9 Incorrect BCD digit Add 6 Correct answer 1 4
  • 13. 13 2) Algorithms for Addition A BCD adder 1001 0101 0001 = 1 0100 = 4 If the result, S3 S2 S1 S0, is not a valid BCD digit, the multiplexer causes 6 to be added to the result.
  • 14. 14 A simple example of subtraction 3) Algorithms for Subtraction 0111 + 1101 0100 (+7) (- 3) (+4) 0011 is 3, the one’s complement is 1100. Each of the computations adds 1 to the one’s complement to produce the two’s complement of the number. 1100 + 1 = 1101 The two’s complement of 3 is 1101
  • 15. 15 3) Algorithms for Subtraction The second change has to do with complements.  The nine’s complement in BCD, generated by subtracting the value to be complemented from another value that has all 9S as its digits. Adding one to this value produces the ten’s complement, the negative of the original value. e.g, the nine’s complement of 631 is 999 – 631 = 368. 368 + 1 = 369 is the ten’s complement
  • 16. 16  The ten’s complement plays the subtraction and negation for BCD numbers. 3) Algorithms for Subtraction Hareware generates the nine’s complement of a single BCD digit.
  • 17. 17 Conclusion for addition and subtraction Using a BCD adder and Nine’s complement generation hardware to compute the addition and the subtraction for signed-magnitude binary numbers The algorithm for adding and subtracting as below: PM’1: US XS, CU X + Y PM1: CU X + Y’ + 1, OVERFLOW 0 PM’2: OVERFLOW C
  • 18. 18 The algorithm for adding and subtracting CZ’PM2: US XS CZPM2: US 0 C’PM2: US X’S, U U’ + 1 2: FINISH 1
  • 19. 19 Example of addition of BCD numbers USU = XSX + YSY XSX = +33 = 0 0011 0011 YSY = +25 = 0 0010 0101 PM’1: US 0, CU 0 0101 1000 PM’2: OVERFLOW 0 Result: USU = 0 0101 1000 = +58
  • 20. 20 Example of subtraction of BCD numbers USU = XSX + YSY XSX = +27 = 0 0010 0111 YSY = -13 = 1 0001 0011 PM1: CU 1 0001 0100, OVERFLOW 0 CZ’PM2: US 0 Result: USU = 0 0001 0100 = +14
  • 21. 21 4) Algorithms for Multiplication 1101 Multiplicand M X 1011 Multiplier Q 1101 1101 0000 1101____ 10001111 Product P
  • 22. 22 4) Algorithms for Multiplication Multiplicand Multiplier Product
  • 23. 23 4) Algorithms for Multiplication Required to use the BCD adder and nine’s complement circuitry. In BCD, each digit of the multiplicand may have any value from 0 to 9; each iteration of the loop may have to perform up to nine additions. We must incorporate an inner loop in the algorithm for these multiple additions. In addition, use decimal shifts right operation (dshr), which shift one BCD digit, or four bits at a time.
  • 24. 24 The BCD multiplication algorithm 1: US XS+YS, VS XS+YS, U 0, i n, Cd 0 ZY0’2: CSU CdU + X, Yd0 Yd0 – 1, GOTO 2 ZY02: i i - 1 3: dshr (CdUV), dshr (Y) Z’3: GOTO 2 ZT3: US 0, VS 0 Z3: FINISH 1 4) Algorithms for Multiplication
  • 25. 25 4) Algorithms for Multiplication
  • 26. 26 Division can be implemented using either a restoring or a non-restoring algorithm. An inner loop to perform multiple subtractions must be incorporated into the algorithm. 5) Algorithms for Division 10 11 ) 1000 11_ 10
  • 27. 27 5) Algorithms for Division A logic circuit arrangement implements the restoring-division technique
  • 28. 28 A restoring-division example Initially 0 0 0 0 0 1 0 0 0 0 0 0 1 1 Shift 0 0 0 0 1 0 0 0 Subtract 1 1 1 0 1 Set q0 1 1 1 1 0 Restore 1 1 0 0 0 0 1 0 0 0 0 Shift 0 0 0 1 0 0 0 0 Subtract 1 1 1 0 1 Set q0 1 1 1 1 1 Restore 1 1 0 0 0 1 0 0 0 0 0 Shift 0 0 1 0 0 0 0 0 Subtract 1 1 1 0 1 Set q0 0 0 0 1 0 0 0 0 1 Shift 0 0 0 1 0 0 0 1 Subtract 1 1 1 0 1 Set q0 1 1 1 1 1 Restore 1 1 0 0 0 1 0 0 0 1 0 remainder Quotient First cycle Second cycle Third cycle Fourth cycle
  • 29. 29 5) Algorithms for Division The restoring-division algorithm: S1: DO n times Shift A and Q left one binary position. Subtract M from A, placing the answer back in A. If the sign of A is 1, set q0 to 0 and add M back to A (restore A); otherwise, set q0 to 1.
  • 30. 30 5) Algorithms for Division The non-restoring division algorithm: S1: Do n times If the sign of A is 0, shift A and Q left one binary position and subtract M from A; otherwise, shift A and Q left and add M to A. S2: If the sign of A is 1, add M to A.
  • 31. 31 References: Computer Systems Organization & Architecture, Addison Wesley Longman, Inc., 2001 Introduction to Computer Organization 4th Edition. V.Carl hamacher. 1998 http:// www.sfxavier.ac.uk/computing/bcd/bcd1.htm http:// www.awl.com/carpinelli