SlideShare a Scribd company logo
1 of 23
Lectures on Complement Theory (1โ€™s and 2โ€™s, 9โ€™s
and 10โ€™s), BCD Addition, Decimal, Octal, and
Hexadecimal Addition
for
Open Educational Resource
on
Logic Development and Programming (EC221)
by
Dr. Piyush Charan
Assistant Professor
Department of Electronics and Communication Engg.
Integral University, Lucknow
2
1. Complement Theory
2. 1โ€™s and, 2โ€™s complement operation
Number System Continued....
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
3
1.Complement Theory
Example 1 Get 1โ€™s complement of 50
Complement Digits
50 = 110010
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
001101
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
4
1โ€™s Complement Arithmetic
(ADD/SUB Method)
1. Read both the operands
2. Negative operand(s) (if any) is converted into 1โ€™s complement form
3. Add both the numbers
4. If carry is generated (i.e. =1) then the resultant number is positive.
5. Add ONE to the output of setp4, to get the final answer.
6. If carry is not generated then the answer is Negative and available in 1โ€™s complement form.
7. Convert output of step 6 into 1โ€™s complement to get final answer.
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
5
1. 1โ€™s Complement Theory
Example 1 : Subtract 1010 from 1111 using 1โ€™s complement theory. (15-10 Small negative)
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
1 0 1 0 0 1 0 1
1 1 1 1
0 1 0 1+
1] 0 1 0 0
+ 0 0 0 1
0 1 0 1 =(5)
1โ€™s complement
Carry โ€œ1โ€ means the answer is positive .
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
6
1. 1โ€™s Complement Theory
Example 2 : Subtract 1010 from 1000 using 1โ€™s complement theory. (Large negative 8-10)
1 0 1 0 0 1 0 1
1 0 0 0
0 1 0 1+
0] 1 1 0 1
1โ€™s complement
Carry โ€œ0โ€ means the answer is negative and available in 1โ€™s complement form.
1 1 0 1 0 0 1 0 = (2)
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
7
2โ€™s Complement Arithmetic
1. How to get 2โ€™s complement form
2. Arithmetic operation using 2โ€™s complement theory
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
8
2โ€™s Complement Arithmetic (How to get 2โ€™s
complement form..?)
Example 1
Example 2
Complement Digits
Add 1
5 = 00000101
-5 = 11111011
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
11111010
+1
Complement Digits
Add 1
-13 = 11110011
13 = 00001101
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
00001100
+1
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
9
2โ€™s Complement Arithmetic
(Method)
1. Read both the operands
2. Negative operand (if any) is converted into 2โ€™s complement form
3. Add both the numbers (2โ€™s complement of negative operand with the other one).
4. If carry is generated (i.e. =1) then the resultant number is positive and in original form
5. If carry is not generated(when we have negative operand) then the carry is assumed =0.
6. Carry zero means the resultant number is negative and in a 2โ€™s complement form.
7. Convert the 2โ€™s complement form into the original form.
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
POS + NEG โ†’ POS Answer
10
Take the 2โ€™s complement of the negative number and use regular binary 8-bit
addition.
000010019
+ (-5)
4
โŽฏโ†’
๏‚ฌโŽฏ
11111011+
00000101
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
11111010
+1
11111011
2โ€™s
Complement
Process
100000100
Last Bit = 1: Answer is Positive Disregard 9th
Bit
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
POS + NEG โ†’ NEG Answer
11
Take the 2โ€™s complement of the negative number and use regular 8-bit
binary addition.
11110111(-9)
+ 5
-4
โŽฏโ†’
๏‚ฌโŽฏ
00000101+
00001001
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
11110110
+1
11110111
2โ€™s
Complement
Process
011111100
Last Bit = 0: Answer is Negative . Discard the last bit
11111100
๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ
00000011
+1
00000100
To Check:
Perform 2โ€™s
Complement
On Answer
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
Verify the logic using following combinations:
1: (10) โ€“(01)
2: (10) โ€“(02)
3: (10) โ€“(05)
4: (10) โ€“(08)
5: (10) โ€“(09)
6: (10) โ€“(10)
7: (210) โ€“(08)
8: (120) โ€“(55)
9: (52) โ€“(18)
01-10-2020 12Dr. Piyush Charan, Dept. of ECE, IU Lucknow
A+B A B 2โ€™s of B Addition Ans
A=10
B=-1
1 0 1 0
0 0 0 1 1 1 1 0
0 0 0 1
1 1 1 1
1 0 1 0
1 1 1 1 CY =1 So ans is +ve
1 1 0 0 1
+9
B=-2 0 0 1 0 1 1 0 1
0 0 0 1
1 1 1 0
1 0 1 0
1 1 1 0 CY =1 So ans is +ve
1 1 0 0 0
+8
B=-5 0 1 0 1 1 0 1 0
0 0 0 1
1 0 1 1
1 0 1 0
1 0 1 1
1 0 1 0 1 CY =1 So ans is +ve
+5
B=-8 1 0 0 0 0 1 1 1
0 0 0 1
1 0 0 0
1 0 1 0
1 0 0 0
1 0 0 1 0 CY =1 So ans is +ve
+2
B=-9 1 0 0 1 0 1 1 0
0 0 0 1
0 1 1 1
1 0 1 0
0 1 1 1
1 0 0 0 1 CY =1 So ans is +ve
+1
B=-10 1 0 1 0 0 1 0 1
0 0 0 1
0 1 1 0
1 0 1 0
0 1 1 0
1 0 0 0 0 CY =1 So ans is +ve
+0
2โ€™s Complement Arithmetic (Examples)
01-10-2020
13Dr. Piyush Charan, Dept. of ECE, IU Lucknow
Example: Perform 2โ€™s complement subtraction on 210-08
210 = 1 1 0 1 0 0 1 0 (Subtrahend)
8= 0 0 0 0 1 0 0 0 (Minuend)
2โ€™s complement of 8 is = 1 1 1 1 1 0 0 0
Add both the numbers:
1 1 0 1 0 0 1 0
+1 1 1 1 1 0 0 0
1 1 1 0 0 1 0 1 0
Carry = 1 means and is positive +202
01-10-2020 14Dr. Piyush Charan, Dept. of ECE, IU Lucknow
15
2โ€™s Complement Arithmetic (Examples on varying
number of bits)
Example: Perform 2โ€™s complement arithmetic for (30)-(50) using
1: 6-bit number system
2: 8-bit number system
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
Example: Perform 2โ€™s complement arithmetic for (30)-(50) using:
(30)= 0 1 1 1 1 0
(-50)= 1 1 0 0 1 0 2โ€™s complement 0 0 1 1 0 1
0 0 0 0 0 1
0 0 1 1 1 0
Add both the numbers
0 1 1 1 1 0
0 0 1 1 1 0
0 1 0 1 1 0 0
Carry =0 means number is negative and in 2โ€™s compl form
(30)= 0 0 0 1 1 1 1 0
(-50)= 0 0 1 1 0 0 1 0 2โ€™s complement 1 1 0 0 1 1 0 1
0 0 0 0 0 0 0 1
1 1 0 0 1 1 1 0
0 0 0 1 1 1 1 0
1 1 0 0 1 1 1 0
0 1 1 1 0 1 1 0 0
Carry =0 means number is negative and in 2โ€™s compl form
0 1 0 0 1 1
0 0 0 0 0 1
0 1 0 1 0 0 = -20
0 0 0 1 0 0 1 1
0 0 0 0 0 0 0 1
0 0 0 1 0 1 0 0 = -20
Add both the numbers
1: 6-bit number system 2: 8-bit number
system
01-10-2020 16Dr. Piyush Charan, Dept. of ECE, IU Lucknow
BCD Numbers
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow 17
01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow 18
1. Binary to decimal Conversion
2. BCD Addition
11/2/2020
Dr. Piyush Charan, Dept. of ECE, Integral University,
Lucknow
19
9โ€™s & 10โ€™s Complement
11/2/2020 20
Dr. Piyush Charan, Dept. of ECE, Integral University,
Lucknow
Decimal(base 10) Addition
11/2/2020
Dr. Piyush Charan, Dept. of ECE, Integral University,
Lucknow
21
Octal (base 8) Addition
11/2/2020 22
Dr. Piyush Charan, Dept. of ECE, Integral University,
Lucknow
Hexadecimal(base 16) Addition
11/2/2020 23
Dr. Piyush Charan, Dept. of ECE, Integral University,
Lucknow

More Related Content

Similar to Unit 2: Data Representation contd.

Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
Shankar Gangaju
ย 
ENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docx
ENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docxENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docx
ENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docx
YASHU40
ย 
Lecture 1-431171839-lec2-BinaryArithmetic.ppt
Lecture 1-431171839-lec2-BinaryArithmetic.pptLecture 1-431171839-lec2-BinaryArithmetic.ppt
Lecture 1-431171839-lec2-BinaryArithmetic.ppt
AhmedWasiu
ย 

Similar to Unit 2: Data Representation contd. (20)

About the computer of the important field
About the computer               of the important fieldAbout the computer               of the important field
About the computer of the important field
ย 
Module 4_Digital Electronics till complements.pdf
Module 4_Digital Electronics till complements.pdfModule 4_Digital Electronics till complements.pdf
Module 4_Digital Electronics till complements.pdf
ย 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
ย 
Unit 4 Switching Theory and Logic Gates
Unit 4 Switching Theory and Logic GatesUnit 4 Switching Theory and Logic Gates
Unit 4 Switching Theory and Logic Gates
ย 
Introduction to Quantum Computing from Math perspective
Introduction to Quantum Computing from Math perspectiveIntroduction to Quantum Computing from Math perspective
Introduction to Quantum Computing from Math perspective
ย 
Logic Design
Logic DesignLogic Design
Logic Design
ย 
PPT 2 - CA unit II 22 7-2020
PPT 2 - CA unit II 22 7-2020PPT 2 - CA unit II 22 7-2020
PPT 2 - CA unit II 22 7-2020
ย 
Digital_Electronics_Basics.pdf
Digital_Electronics_Basics.pdfDigital_Electronics_Basics.pdf
Digital_Electronics_Basics.pdf
ย 
1โ€™s and 2โ€™s complements
1โ€™s and 2โ€™s complements1โ€™s and 2โ€™s complements
1โ€™s and 2โ€™s complements
ย 
Two-sample Hypothesis Tests
Two-sample Hypothesis Tests Two-sample Hypothesis Tests
Two-sample Hypothesis Tests
ย 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
ย 
Chapter_02_The_Language_of_Bits_Any.pptx
Chapter_02_The_Language_of_Bits_Any.pptxChapter_02_The_Language_of_Bits_Any.pptx
Chapter_02_The_Language_of_Bits_Any.pptx
ย 
Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
ย 
Unit 02
Unit 02Unit 02
Unit 02
ย 
ENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docx
ENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docxENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docx
ENGR 232Dynamic Engineering SystemsLecture 1.2 - App.docx
ย 
Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
ย 
B sc3 unit 2 number system
B sc3  unit 2 number systemB sc3  unit 2 number system
B sc3 unit 2 number system
ย 
Digital Electronics and Computer Language
Digital Electronics and Computer Language Digital Electronics and Computer Language
Digital Electronics and Computer Language
ย 
Lecture 1-431171839-lec2-BinaryArithmetic.ppt
Lecture 1-431171839-lec2-BinaryArithmetic.pptLecture 1-431171839-lec2-BinaryArithmetic.ppt
Lecture 1-431171839-lec2-BinaryArithmetic.ppt
ย 
B sc ii sem unit 2(a) ns
B sc ii sem  unit 2(a) nsB sc ii sem  unit 2(a) ns
B sc ii sem unit 2(a) ns
ย 

More from Dr Piyush Charan

More from Dr Piyush Charan (20)

Unit 1- Intro to Wireless Standards.pdf
Unit 1- Intro to Wireless Standards.pdfUnit 1- Intro to Wireless Standards.pdf
Unit 1- Intro to Wireless Standards.pdf
ย 
Unit 1 Solar Collectors
Unit 1 Solar CollectorsUnit 1 Solar Collectors
Unit 1 Solar Collectors
ย 
Unit 5 Quantization
Unit 5 QuantizationUnit 5 Quantization
Unit 5 Quantization
ย 
Unit 4 Lossy Coding Preliminaries
Unit 4 Lossy Coding PreliminariesUnit 4 Lossy Coding Preliminaries
Unit 4 Lossy Coding Preliminaries
ย 
Unit 3 Geothermal Energy
Unit 3 Geothermal EnergyUnit 3 Geothermal Energy
Unit 3 Geothermal Energy
ย 
Unit 2: Programming Language Tools
Unit 2:  Programming Language ToolsUnit 2:  Programming Language Tools
Unit 2: Programming Language Tools
ย 
Unit 4 Arrays
Unit 4 ArraysUnit 4 Arrays
Unit 4 Arrays
ย 
Unit 3 Lecture Notes on Programming
Unit 3 Lecture Notes on ProgrammingUnit 3 Lecture Notes on Programming
Unit 3 Lecture Notes on Programming
ย 
Unit 3 introduction to programming
Unit 3 introduction to programmingUnit 3 introduction to programming
Unit 3 introduction to programming
ย 
Forensics and wireless body area networks
Forensics and wireless body area networksForensics and wireless body area networks
Forensics and wireless body area networks
ย 
Final PhD Defense Presentation
Final PhD Defense PresentationFinal PhD Defense Presentation
Final PhD Defense Presentation
ย 
Unit 3 Arithmetic Coding
Unit 3 Arithmetic CodingUnit 3 Arithmetic Coding
Unit 3 Arithmetic Coding
ย 
Unit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman codingUnit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman coding
ย 
Unit 1 Introduction to Data Compression
Unit 1 Introduction to Data CompressionUnit 1 Introduction to Data Compression
Unit 1 Introduction to Data Compression
ย 
Unit 3 Dictionary based Compression Techniques
Unit 3 Dictionary based Compression TechniquesUnit 3 Dictionary based Compression Techniques
Unit 3 Dictionary based Compression Techniques
ย 
Unit 1 Introduction to Non-Conventional Energy Resources
Unit 1 Introduction to Non-Conventional Energy ResourcesUnit 1 Introduction to Non-Conventional Energy Resources
Unit 1 Introduction to Non-Conventional Energy Resources
ย 
Unit 5-Operational Amplifiers and Electronic Measurement Devices
Unit 5-Operational Amplifiers and Electronic Measurement DevicesUnit 5-Operational Amplifiers and Electronic Measurement Devices
Unit 5-Operational Amplifiers and Electronic Measurement Devices
ย 
Unit 1 Introduction to Data Compression
Unit 1 Introduction to Data CompressionUnit 1 Introduction to Data Compression
Unit 1 Introduction to Data Compression
ย 
Unit 1 Numerical Problems on PN Junction Diode
Unit 1 Numerical Problems on PN Junction DiodeUnit 1 Numerical Problems on PN Junction Diode
Unit 1 Numerical Problems on PN Junction Diode
ย 
Unit 5 Global Issues- Early life of Prophet Muhammad
Unit 5 Global Issues- Early life of Prophet MuhammadUnit 5 Global Issues- Early life of Prophet Muhammad
Unit 5 Global Issues- Early life of Prophet Muhammad
ย 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
sivaprakash250
ย 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
ย 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
SUHANI PANDEY
ย 
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 

Recently uploaded (20)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ย 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
ย 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
ย 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
ย 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
ย 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
ย 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
ย 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
ย 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
ย 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
ย 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
ย 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
ย 
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
ย 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
ย 

Unit 2: Data Representation contd.

  • 1. Lectures on Complement Theory (1โ€™s and 2โ€™s, 9โ€™s and 10โ€™s), BCD Addition, Decimal, Octal, and Hexadecimal Addition for Open Educational Resource on Logic Development and Programming (EC221) by Dr. Piyush Charan Assistant Professor Department of Electronics and Communication Engg. Integral University, Lucknow
  • 2. 2 1. Complement Theory 2. 1โ€™s and, 2โ€™s complement operation Number System Continued.... 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 3. 3 1.Complement Theory Example 1 Get 1โ€™s complement of 50 Complement Digits 50 = 110010 ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 001101 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 4. 4 1โ€™s Complement Arithmetic (ADD/SUB Method) 1. Read both the operands 2. Negative operand(s) (if any) is converted into 1โ€™s complement form 3. Add both the numbers 4. If carry is generated (i.e. =1) then the resultant number is positive. 5. Add ONE to the output of setp4, to get the final answer. 6. If carry is not generated then the answer is Negative and available in 1โ€™s complement form. 7. Convert output of step 6 into 1โ€™s complement to get final answer. 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 5. 5 1. 1โ€™s Complement Theory Example 1 : Subtract 1010 from 1111 using 1โ€™s complement theory. (15-10 Small negative) ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 1 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1+ 1] 0 1 0 0 + 0 0 0 1 0 1 0 1 =(5) 1โ€™s complement Carry โ€œ1โ€ means the answer is positive . 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 6. 6 1. 1โ€™s Complement Theory Example 2 : Subtract 1010 from 1000 using 1โ€™s complement theory. (Large negative 8-10) 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 1+ 0] 1 1 0 1 1โ€™s complement Carry โ€œ0โ€ means the answer is negative and available in 1โ€™s complement form. 1 1 0 1 0 0 1 0 = (2) 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 7. 7 2โ€™s Complement Arithmetic 1. How to get 2โ€™s complement form 2. Arithmetic operation using 2โ€™s complement theory 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 8. 8 2โ€™s Complement Arithmetic (How to get 2โ€™s complement form..?) Example 1 Example 2 Complement Digits Add 1 5 = 00000101 -5 = 11111011 ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 11111010 +1 Complement Digits Add 1 -13 = 11110011 13 = 00001101 ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 00001100 +1 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 9. 9 2โ€™s Complement Arithmetic (Method) 1. Read both the operands 2. Negative operand (if any) is converted into 2โ€™s complement form 3. Add both the numbers (2โ€™s complement of negative operand with the other one). 4. If carry is generated (i.e. =1) then the resultant number is positive and in original form 5. If carry is not generated(when we have negative operand) then the carry is assumed =0. 6. Carry zero means the resultant number is negative and in a 2โ€™s complement form. 7. Convert the 2โ€™s complement form into the original form. 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 10. POS + NEG โ†’ POS Answer 10 Take the 2โ€™s complement of the negative number and use regular binary 8-bit addition. 000010019 + (-5) 4 โŽฏโ†’ ๏‚ฌโŽฏ 11111011+ 00000101 ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 11111010 +1 11111011 2โ€™s Complement Process 100000100 Last Bit = 1: Answer is Positive Disregard 9th Bit 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 11. POS + NEG โ†’ NEG Answer 11 Take the 2โ€™s complement of the negative number and use regular 8-bit binary addition. 11110111(-9) + 5 -4 โŽฏโ†’ ๏‚ฌโŽฏ 00000101+ 00001001 ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 11110110 +1 11110111 2โ€™s Complement Process 011111100 Last Bit = 0: Answer is Negative . Discard the last bit 11111100 ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ๏‚ฏ 00000011 +1 00000100 To Check: Perform 2โ€™s Complement On Answer 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 12. Verify the logic using following combinations: 1: (10) โ€“(01) 2: (10) โ€“(02) 3: (10) โ€“(05) 4: (10) โ€“(08) 5: (10) โ€“(09) 6: (10) โ€“(10) 7: (210) โ€“(08) 8: (120) โ€“(55) 9: (52) โ€“(18) 01-10-2020 12Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 13. A+B A B 2โ€™s of B Addition Ans A=10 B=-1 1 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 CY =1 So ans is +ve 1 1 0 0 1 +9 B=-2 0 0 1 0 1 1 0 1 0 0 0 1 1 1 1 0 1 0 1 0 1 1 1 0 CY =1 So ans is +ve 1 1 0 0 0 +8 B=-5 0 1 0 1 1 0 1 0 0 0 0 1 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 CY =1 So ans is +ve +5 B=-8 1 0 0 0 0 1 1 1 0 0 0 1 1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 CY =1 So ans is +ve +2 B=-9 1 0 0 1 0 1 1 0 0 0 0 1 0 1 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 CY =1 So ans is +ve +1 B=-10 1 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 0 0 0 CY =1 So ans is +ve +0 2โ€™s Complement Arithmetic (Examples) 01-10-2020 13Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 14. Example: Perform 2โ€™s complement subtraction on 210-08 210 = 1 1 0 1 0 0 1 0 (Subtrahend) 8= 0 0 0 0 1 0 0 0 (Minuend) 2โ€™s complement of 8 is = 1 1 1 1 1 0 0 0 Add both the numbers: 1 1 0 1 0 0 1 0 +1 1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 0 Carry = 1 means and is positive +202 01-10-2020 14Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 15. 15 2โ€™s Complement Arithmetic (Examples on varying number of bits) Example: Perform 2โ€™s complement arithmetic for (30)-(50) using 1: 6-bit number system 2: 8-bit number system 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 16. Example: Perform 2โ€™s complement arithmetic for (30)-(50) using: (30)= 0 1 1 1 1 0 (-50)= 1 1 0 0 1 0 2โ€™s complement 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 1 0 Add both the numbers 0 1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0 Carry =0 means number is negative and in 2โ€™s compl form (30)= 0 0 0 1 1 1 1 0 (-50)= 0 0 1 1 0 0 1 0 2โ€™s complement 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 0 0 Carry =0 means number is negative and in 2โ€™s compl form 0 1 0 0 1 1 0 0 0 0 0 1 0 1 0 1 0 0 = -20 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 = -20 Add both the numbers 1: 6-bit number system 2: 8-bit number system 01-10-2020 16Dr. Piyush Charan, Dept. of ECE, IU Lucknow
  • 17. BCD Numbers 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow 17
  • 18. 01-10-2020 Dr. Piyush Charan, Dept. of ECE, IU Lucknow 18
  • 19. 1. Binary to decimal Conversion 2. BCD Addition 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 19
  • 20. 9โ€™s & 10โ€™s Complement 11/2/2020 20 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow
  • 21. Decimal(base 10) Addition 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 21
  • 22. Octal (base 8) Addition 11/2/2020 22 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow
  • 23. Hexadecimal(base 16) Addition 11/2/2020 23 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow