SlideShare a Scribd company logo
1 of 19
Digital Electronics
2’s Complement Arithmetic
2’s Complement Arithmetic
This presentation will demonstrate
• That subtracting one number from another is
the same as making one number negative
and adding.
• How to create negative numbers in the binary
number system.
• The 2’s Complement Process.
• How the 2’s complement process can be use
to add (and subtract) binary numbers.
2
Negative Numbers?
• Digital electronics requires frequent addition and
subtraction of numbers. You know how to design
an adder, but what about a subtract-er?
• A subtract-er is not needed with the 2’s
complement process. The 2’s complement
process allows you to easily convert a positive
number into its negative equivalent.
• Since subtracting one number from another is
the same as making one number negative and
adding, the need for a subtract-er circuit has
been eliminated. 3
How To Create A Negative Number
• In digital electronics you cannot simply put a
minus sign in front of a number to make it
negative.
• You must represent a negative number in a fixed-
length binary number system. All signed
arithmetic must be performed in a fixed-length
number system.
• A physical fixed-length device (usually memory)
contains a fixed number of bits (usually 4-bits, 8-
bits, 16-bits) to hold the number.
4
3-Digit Decimal Number System
A bicycle odometer with only
three digits is an example of a
fixed-length decimal number
system.
The problem is that without a
negative sign, you cannot tell
a +998 from a -2 (also a 998).
Did you ride forward for 998
miles or backward for 2 miles?
Note: Car odometers do not work this way.
5
999
998
997
001
000
999
998
002
001
forward (+)
backward (-)
Negative Decimal
How do we represent
negative numbers in this 3-
digit decimal number system
without using a sign?
Cut the number system in half.
Use 001 – 499 to indicate
positive numbers.
Use 500 – 999 to indicate
negative numbers.
Notice that 000 is not positive
or negative.
6
499
498
497
001
000
999
998
501
500
pos(+)
neg(-)
+499
+498
+497
+001
000
-001
-002
-499
-500
“Odometer” Math Examples
7
3
+ 2
5
003
+ 002
005
(-5)
+ 2
(-3)
995
+ 002
997
6
+ (-3)
3
(-2)
+ (-3)
(-5)
006
+ 997
1003
Disregard
Overflow
998
+ 997
1995
Disregard
Overflow
It Works!
Complex Problems
• The previous examples demonstrate that this
process works, but how do we easily convert a
number into its negative equivalent?
• In the examples, converting the negative numbers
into the 3-digit decimal number system was fairly
easy. To convert the (-3), you simply counted
backward from 1000 (i.e., 999, 998, 997).
• This process is not as easy for large numbers
(e.g., -214 is 786). How did we determine this?
• To convert a large negative number, you can use
the 10’s Complement Process.
8
10’s Complement Process
The 10’s Complement process uses base-10
(decimal) numbers. Later, when we’re working with
base-2 (binary) numbers, you will see that the 2’s
Complement process works in the same way.
First, complement all of the digits in a number.
– A digit’s complement is the number you add to the digit to
make it equal to the largest digit in the base (i.e., 9 for
decimal). The complement of 0 is 9, 1 is 8, 2 is 7, etc.
Second, add 1.
– Without this step, our number system would have two
zeroes (+0 & -0), which no number system has.
9
10’s Complement Examples
10
-003
+1

996
997
-214
+1

785
786
Example #1
Example #2
Complement Digits
Add 1
Complement Digits
Add 1
8-Bit Binary Number System
Apply what you have learned to the
binary number systems. How do you
represent negative numbers in this 8-bit
binary system?
Cut the number system in half.
Use 00000001 – 01111111 to indicate
positive numbers.
Use 10000000 – 11111111 to indicate
negative numbers.
Notice that 00000000 is not positive or
negative. 11
01111111
01111110
01111101
00000001
00000000
11111111
11111110
10000001
10000000
pos(+)
neg(-)
+127
+126
+125
+1
0
-1
-2
-127
-128
Sign Bit
• What did do you notice about the
most significant bit of the binary
numbers?
• The MSB is (0) for all positive
numbers.
• The MSB is (1) for all negative
numbers.
• The MSB is called the sign bit.
• In a signed number system, this
allows you to instantly determine
whether a number is positive or
negative.
12
01111111
01111110
01111101
00000001
00000000
11111111
11111110
10000001
10000000
pos(+)
neg(-)
+127
+126
+125
+1
0
-1
-2
-127
-128
2’S Complement Process
The steps in the 2’s Complement process are similar
to the 10’s Complement process. However, you will
now use the base two.
First, complement all of the digits in a number.
– A digit’s complement is the number you add to the digit to
make it equal to the largest digit in the base (i.e., 1 for
binary). In binary language, the complement of 0 is 1, and
the complement of 1 is 0.
Second, add 1.
– Without this step, our number system would have two
zeroes (+0 & -0), which no number system has.
13
2’s Complement Examples
14
Example #1
Example #2
Complement Digits
Add 1
5 = 00000101
-5 = 11111011

11111010
+1
Complement Digits
Add 1
-13 = 11110011
13 = 00001101

00001100
+1
Using The 2’s Compliment Process
15
9
+ (-5)
4
(-9)
+ 5
- 4
(-9)
+ (-5)
- 14
9
+ 5
14
POS
+ POS
POS

POS
+ NEG
POS

NEG
+ POS
NEG

NEG
+ NEG
NEG

Use the 2’s complement process to add together
the following numbers.
POS + POS → POS Answer
16
If no 2’s complement is needed, use regular binary
addition.
00001001
9
+ 5
14

 00001110
00000101
 +
POS + NEG → POS Answer
17
Take the 2’s complement of the negative number and
use regular binary addition.
00001001
9
+ (-5)
4


11111011
+
00000101

11111010
+1
11111011
2’s
Complement
Process
1]00000100
8th Bit = 0: Answer is Positive
Disregard 9th Bit
POS + NEG → NEG Answer
18
Take the 2’s complement of the negative number and
use regular binary addition.
11110111
(-9)
+ 5
-4


00000101
+
00001001

11110110
+1
11110111
2’s
Complement
Process
11111100
8th Bit = 1: Answer is Negative
11111100

00000011
+1
00000100
To Check:
Perform 2’s
Complement
On Answer
NEG + NEG → NEG Answer
19
Take the 2’s complement of both negative numbers and
use regular binary addition.
11110111
(-9)
+ (-5)
-14


11111011
 +
2’s Complement
Numbers, See
Conversion Process
In Previous Slides
1]11110010
8th Bit = 1: Answer is Negative
Disregard 9th Bit
11110010

00001101
+1
00001110
To Check:
Perform 2’s
Complement
On Answer

More Related Content

Similar to 2sComplementArithmetic1.ppt

Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemISMT College
 
UNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhgghUNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhgghKwadjoOwusuAnsahQuar
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfTamiratDejene1
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001aarunachalamr16
 
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...Arti Parab Academics
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...Arti Parab Academics
 
Chapter iii: Number System
Chapter iii: Number SystemChapter iii: Number System
Chapter iii: Number Systemkclove
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesDr. Anita Goel
 
data representation
 data representation data representation
data representationHaroon_007
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptxMtikuTadesse
 
Arithmetic Operations
Arithmetic OperationsArithmetic Operations
Arithmetic Operationsgueste99d9a
 
Arithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsArithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsS N M P Simamora
 
Week 4-Number Systems.pptx
Week 4-Number Systems.pptxWeek 4-Number Systems.pptx
Week 4-Number Systems.pptxHamnaKhalid25
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representationgavhays
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptskatiarrahaman
 

Similar to 2sComplementArithmetic1.ppt (20)

Complement
ComplementComplement
Complement
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
UNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhgghUNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhggh
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
 
Chapter iii: Number System
Chapter iii: Number SystemChapter iii: Number System
Chapter iii: Number System
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
Representation of Negative Numbers
Representation of Negative NumbersRepresentation of Negative Numbers
Representation of Negative Numbers
 
data representation
 data representation data representation
data representation
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
 
Arithmetic Operations
Arithmetic OperationsArithmetic Operations
Arithmetic Operations
 
Arithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsArithmetic Process in Computer Systems
Arithmetic Process in Computer Systems
 
Week 4-Number Systems.pptx
Week 4-Number Systems.pptxWeek 4-Number Systems.pptx
Week 4-Number Systems.pptx
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 

Recently uploaded

High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 

Recently uploaded (20)

High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 

2sComplementArithmetic1.ppt

  • 2. 2’s Complement Arithmetic This presentation will demonstrate • That subtracting one number from another is the same as making one number negative and adding. • How to create negative numbers in the binary number system. • The 2’s Complement Process. • How the 2’s complement process can be use to add (and subtract) binary numbers. 2
  • 3. Negative Numbers? • Digital electronics requires frequent addition and subtraction of numbers. You know how to design an adder, but what about a subtract-er? • A subtract-er is not needed with the 2’s complement process. The 2’s complement process allows you to easily convert a positive number into its negative equivalent. • Since subtracting one number from another is the same as making one number negative and adding, the need for a subtract-er circuit has been eliminated. 3
  • 4. How To Create A Negative Number • In digital electronics you cannot simply put a minus sign in front of a number to make it negative. • You must represent a negative number in a fixed- length binary number system. All signed arithmetic must be performed in a fixed-length number system. • A physical fixed-length device (usually memory) contains a fixed number of bits (usually 4-bits, 8- bits, 16-bits) to hold the number. 4
  • 5. 3-Digit Decimal Number System A bicycle odometer with only three digits is an example of a fixed-length decimal number system. The problem is that without a negative sign, you cannot tell a +998 from a -2 (also a 998). Did you ride forward for 998 miles or backward for 2 miles? Note: Car odometers do not work this way. 5 999 998 997 001 000 999 998 002 001 forward (+) backward (-)
  • 6. Negative Decimal How do we represent negative numbers in this 3- digit decimal number system without using a sign? Cut the number system in half. Use 001 – 499 to indicate positive numbers. Use 500 – 999 to indicate negative numbers. Notice that 000 is not positive or negative. 6 499 498 497 001 000 999 998 501 500 pos(+) neg(-) +499 +498 +497 +001 000 -001 -002 -499 -500
  • 7. “Odometer” Math Examples 7 3 + 2 5 003 + 002 005 (-5) + 2 (-3) 995 + 002 997 6 + (-3) 3 (-2) + (-3) (-5) 006 + 997 1003 Disregard Overflow 998 + 997 1995 Disregard Overflow It Works!
  • 8. Complex Problems • The previous examples demonstrate that this process works, but how do we easily convert a number into its negative equivalent? • In the examples, converting the negative numbers into the 3-digit decimal number system was fairly easy. To convert the (-3), you simply counted backward from 1000 (i.e., 999, 998, 997). • This process is not as easy for large numbers (e.g., -214 is 786). How did we determine this? • To convert a large negative number, you can use the 10’s Complement Process. 8
  • 9. 10’s Complement Process The 10’s Complement process uses base-10 (decimal) numbers. Later, when we’re working with base-2 (binary) numbers, you will see that the 2’s Complement process works in the same way. First, complement all of the digits in a number. – A digit’s complement is the number you add to the digit to make it equal to the largest digit in the base (i.e., 9 for decimal). The complement of 0 is 9, 1 is 8, 2 is 7, etc. Second, add 1. – Without this step, our number system would have two zeroes (+0 & -0), which no number system has. 9
  • 10. 10’s Complement Examples 10 -003 +1  996 997 -214 +1  785 786 Example #1 Example #2 Complement Digits Add 1 Complement Digits Add 1
  • 11. 8-Bit Binary Number System Apply what you have learned to the binary number systems. How do you represent negative numbers in this 8-bit binary system? Cut the number system in half. Use 00000001 – 01111111 to indicate positive numbers. Use 10000000 – 11111111 to indicate negative numbers. Notice that 00000000 is not positive or negative. 11 01111111 01111110 01111101 00000001 00000000 11111111 11111110 10000001 10000000 pos(+) neg(-) +127 +126 +125 +1 0 -1 -2 -127 -128
  • 12. Sign Bit • What did do you notice about the most significant bit of the binary numbers? • The MSB is (0) for all positive numbers. • The MSB is (1) for all negative numbers. • The MSB is called the sign bit. • In a signed number system, this allows you to instantly determine whether a number is positive or negative. 12 01111111 01111110 01111101 00000001 00000000 11111111 11111110 10000001 10000000 pos(+) neg(-) +127 +126 +125 +1 0 -1 -2 -127 -128
  • 13. 2’S Complement Process The steps in the 2’s Complement process are similar to the 10’s Complement process. However, you will now use the base two. First, complement all of the digits in a number. – A digit’s complement is the number you add to the digit to make it equal to the largest digit in the base (i.e., 1 for binary). In binary language, the complement of 0 is 1, and the complement of 1 is 0. Second, add 1. – Without this step, our number system would have two zeroes (+0 & -0), which no number system has. 13
  • 14. 2’s Complement Examples 14 Example #1 Example #2 Complement Digits Add 1 5 = 00000101 -5 = 11111011  11111010 +1 Complement Digits Add 1 -13 = 11110011 13 = 00001101  00001100 +1
  • 15. Using The 2’s Compliment Process 15 9 + (-5) 4 (-9) + 5 - 4 (-9) + (-5) - 14 9 + 5 14 POS + POS POS  POS + NEG POS  NEG + POS NEG  NEG + NEG NEG  Use the 2’s complement process to add together the following numbers.
  • 16. POS + POS → POS Answer 16 If no 2’s complement is needed, use regular binary addition. 00001001 9 + 5 14   00001110 00000101  +
  • 17. POS + NEG → POS Answer 17 Take the 2’s complement of the negative number and use regular binary addition. 00001001 9 + (-5) 4   11111011 + 00000101  11111010 +1 11111011 2’s Complement Process 1]00000100 8th Bit = 0: Answer is Positive Disregard 9th Bit
  • 18. POS + NEG → NEG Answer 18 Take the 2’s complement of the negative number and use regular binary addition. 11110111 (-9) + 5 -4   00000101 + 00001001  11110110 +1 11110111 2’s Complement Process 11111100 8th Bit = 1: Answer is Negative 11111100  00000011 +1 00000100 To Check: Perform 2’s Complement On Answer
  • 19. NEG + NEG → NEG Answer 19 Take the 2’s complement of both negative numbers and use regular binary addition. 11110111 (-9) + (-5) -14   11111011  + 2’s Complement Numbers, See Conversion Process In Previous Slides 1]11110010 8th Bit = 1: Answer is Negative Disregard 9th Bit 11110010  00001101 +1 00001110 To Check: Perform 2’s Complement On Answer

Editor's Notes

  1. Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics
  2. Introductory Slide / Overview of Presentation
  3. This slide explains the need to negative number and why we don’t have subtract-er circuits.
  4. This slide explains why we need a way to represent negative numbers. It introduces the concept of a fixed-length number system.
  5. Before we examine negative binary numbers, let’s first look at something we understand very well: the decimal number system. This slide uses a fixed-length decimal number system to illustrate the limitation of not being able to use a minus sign.
  6. This slide explains how to represent negative numbers in a fix-length decimal number system.
  7. Here are four example of adding two numbers in the odometer number system (i.e., 3-digit decimal number system).
  8. This slide describes the 10’s complement conversion process.
  9. Examples of the 10’s Complement Process.
  10. Introduction to the 8-Bit Binary Number system and how negative numbers are represented.
  11. Explanation of the sign bit.
  12. This slide describes the 2’s complement conversion process.
  13. Examples of the 2’s Complement Process.
  14. This slide show that there are only four possible combinations for adding together two signed numbers. The next four slides demonstrate each of these examples.
  15. Addition of two Positive numbers.
  16. This example shows the addition of one positive and one negative numbers. Note that this is done in the same way as subtracting a positive number from a positive number. In this case, the answer is positive.
  17. This slide demonstrates the addition of one positive and one negative number. Again, this is is the same a subtracting a positive number from a positive number. In this case the answer happens to be negative.
  18. This slide demonstrates the addition of two negative numbers.