SlideShare a Scribd company logo
2’s Complement Arithmetic
Digital Electronics
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 fixedlength 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, 8bits, 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.

999

forward (+)

998
997

001
000
999
998

002
001

backward (-)
5
Negative Decimal
How do we represent
negative numbers in this 3digit decimal number system
without using a sign?

+499

499

+498

498

+497

497

Cut the number system in half.

+001

001

Use 001 – 499 to indicate
positive numbers.

000

000

-001

999

-002

998

-499

501

-500

500

Use 500 – 999 to indicate
negative numbers.
Notice that 000 is not positive
or negative.

pos(+)

neg(-)
6
“Odometer” Math Examples
3
+ 2
5

003
+ 002
005

6
+ (-3)

006
+ 997

3

1]003

(-5)
+ 2

995
+ 002

(-2)
+ (-3)

998
+ 997

(-3)

997

(-5)

1]995

It Works!

Disregard
Overflow

Disregard
Overflow
7
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
Example #1
-003
↓↓↓
996
+1
997

Complement Digits

Add 1

Example #2
-214
↓↓↓
785
+1
786

Complement Digits

Add 1

10
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?

Use 00000001 – 01111111 to indicate
positive numbers.
Use 10000000 – 11111111 to indicate
negative numbers.
Notice that 00000000 is not positive or
negative.

01111111

+126

01111110

+125

01111101

+1

00000001

0

00000000

-1

11111111

-2

Cut the number system in half.

+127

11111110

-127

10000001

-128

10000000

pos(+)

neg(-)
11
Sign Bit
•

•
•

What did do you notice about the
most significant bit of the binary
numbers?
The MSB is (0) for all positive
numbers.

+127

01111111

+126

01111110

+125

01111101

+1

00000001

The MSB is (1) for all negative
numbers.

0

00000000

-1

11111111

•

The MSB is called the sign bit.

-2

11111110

•

In a signed number system, this
allows you to instantly determine
whether a number is positive or
negative.

-127

10000001

-128

10000000

pos(+)

neg(-)
12
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
Example #1
5 = 00000101
↓↓↓↓↓↓↓↓
11111010
+1

Complement Digits

Add 1

-5 = 11111011

Example #2
-13 = 11110011
↓↓↓↓↓↓↓↓
00001100
+1

13 = 00001101

Complement Digits

Add 1

14
Using The 2’s Compliment Process
Use the 2’s complement process to add together
the following numbers.

POS
+ POS
POS

9
⇒+ 5
14

NEG
+ POS
NEG

⇒

POS
+ NEG
POS

9
⇒ + (-5)
4

NEG
+ NEG
NEG

(-9)
⇒ + (-5)
- 14

(-9)
+ 5
-4

15
POS + POS → POS Answer
If no 2’s complement is needed, use regular binary
addition.

9
+ 5
14

→
→

00001001
+ 00000101

←

00001110

16
POS + NEG → POS Answer
Take the 2’s complement of the negative number and
use regular binary addition.

9
+ (-5)
4

→
←

00001001
+ 11111011
1]00000100
8th Bit = 0: Answer is Positive
Disregard 9th Bit

00000101
↓↓↓↓↓↓↓↓
11111010
+1
11111011

2’s
Complement
Process
17
POS + NEG → NEG Answer
Take the 2’s complement of the negative number and
use regular binary addition.

(-9)
+ 5
-4

→
←

11110111
+ 00000101
11111100
8th Bit = 1: Answer is Negative

To Check:
Perform 2’s
Complement
On Answer

11111100
↓↓↓↓↓↓↓↓
00000011
+1
00000100

00001001
↓↓↓↓↓↓↓↓
11110110
+1
11110111

2’s
Complement
Process
18
NEG + NEG → NEG Answer
Take the 2’s complement of both negative numbers and
use regular binary addition.

(-9)
+ (-5)
-14

→
→
←

11110111
+ 11111011
1]11110010

2’s Complement
Numbers, See
Conversion Process
In Previous Slides

8th Bit = 1: Answer is Negative
Disregard 9th Bit

To Check:
Perform 2’s
Complement
On Answer

11110010
↓↓↓↓↓↓↓↓
00001101
+1
00001110

19

More Related Content

What's hot

Procedural programming
Procedural programmingProcedural programming
Procedural programming
Ankit92Chitnavis
 
Computer Organization and Assembly Language
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Language
fasihuddin90
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
.AIR UNIVERSITY ISLAMABAD
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
sonalikharade3
 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
SARASWATHI S
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
Asif Iqbal
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
03062679929
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
Usman Bin Saad
 
Gray Code.pptx
Gray Code.pptxGray Code.pptx
Gray Code.pptx
Pooja Dixit
 
Semaphore
SemaphoreSemaphore
Semaphore
Arafat Hossan
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
Amar Jukuntla
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
sanchi29
 
Pipeline processing and space time diagram
Pipeline processing and space time diagramPipeline processing and space time diagram
Pipeline processing and space time diagram
Rahul Sharma
 
Cpu registers
Cpu registersCpu registers
Cpu registers
Puneet Rajput
 
Microprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal numberMicroprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal number
Sukanta Dutta
 
6 multiprogramming & time sharing
6 multiprogramming & time sharing6 multiprogramming & time sharing
6 multiprogramming & time sharingmyrajendra
 
Linker and Loader Explained
Linker and Loader  ExplainedLinker and Loader  Explained
Linker and Loader Explained
Adarsh Kr Sinha
 
pipelining
pipeliningpipelining
pipelining
Siddique Ibrahim
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
Deepmala Sharma
 

What's hot (20)

Procedural programming
Procedural programmingProcedural programming
Procedural programming
 
Computer Organization and Assembly Language
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Language
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
 
Gray Code.pptx
Gray Code.pptxGray Code.pptx
Gray Code.pptx
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 
Pipeline processing and space time diagram
Pipeline processing and space time diagramPipeline processing and space time diagram
Pipeline processing and space time diagram
 
Cpu registers
Cpu registersCpu registers
Cpu registers
 
Microprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal numberMicroprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal number
 
6 multiprogramming & time sharing
6 multiprogramming & time sharing6 multiprogramming & time sharing
6 multiprogramming & time sharing
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Linker and Loader Explained
Linker and Loader  ExplainedLinker and Loader  Explained
Linker and Loader Explained
 
pipelining
pipeliningpipelining
pipelining
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 

Viewers also liked

1s and 2s complement
1s and 2s complement1s and 2s complement
1s and 2s complement
Then Murugeshwari
 
Complements
ComplementsComplements
Complements
Sudheesh S Madhav
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
mayannpolisticoLNU
 
Math1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's ComplementMath1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's Complementgcmath1003
 
1's and 2's complement
1's and 2's complement 1's and 2's complement
1's and 2's complement
Shiraz Azeem
 
SYSTEMS DESIGN / CAPSTONE PROJECT
SYSTEMS DESIGN / CAPSTONE PROJECTSYSTEMS DESIGN / CAPSTONE PROJECT
SYSTEMS DESIGN / CAPSTONE PROJECT
Sanjay Saluth
 
Math1003 - An Intro to Number Systems
Math1003 - An Intro to Number SystemsMath1003 - An Intro to Number Systems
Math1003 - An Intro to Number Systemsgcmath1003
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
Balakrishna Chowdary
 
Number System
Number SystemNumber System
Number System
samarthagrawal
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
Rai University
 
Digital logic mohammed salim ch3
Digital logic mohammed salim ch3Digital logic mohammed salim ch3
Digital logic mohammed salim ch3
Asst Lect Mohammed Salim
 
review of number systems and codes
review of number systems and codesreview of number systems and codes
review of number systems and codes
srinu247
 
EMBEDDED SYSTEMS 6
EMBEDDED SYSTEMS 6EMBEDDED SYSTEMS 6
EMBEDDED SYSTEMS 6PRADEEP
 
Binary addition
Binary additionBinary addition
Binary addition
Martin Jacob
 
Telecommunication Network 1
Telecommunication Network 1Telecommunication Network 1
Telecommunication Network 1
Sanjay Saluth
 
Software Engineering
Software EngineeringSoftware Engineering
Software EngineeringSanjay Saluth
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
Sanjay Saluth
 
Digital logic mohammed salim ch2
Digital logic mohammed salim ch2Digital logic mohammed salim ch2
Digital logic mohammed salim ch2
Asst Lect Mohammed Salim
 

Viewers also liked (20)

1s and 2s complement
1s and 2s complement1s and 2s complement
1s and 2s complement
 
Complements
ComplementsComplements
Complements
 
2's complement
2's complement2's complement
2's complement
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
Math1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's ComplementMath1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's Complement
 
1's and 2's complement
1's and 2's complement 1's and 2's complement
1's and 2's complement
 
SYSTEMS DESIGN / CAPSTONE PROJECT
SYSTEMS DESIGN / CAPSTONE PROJECTSYSTEMS DESIGN / CAPSTONE PROJECT
SYSTEMS DESIGN / CAPSTONE PROJECT
 
Math1003 - An Intro to Number Systems
Math1003 - An Intro to Number SystemsMath1003 - An Intro to Number Systems
Math1003 - An Intro to Number Systems
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Number System
Number SystemNumber System
Number System
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
 
Digital logic mohammed salim ch3
Digital logic mohammed salim ch3Digital logic mohammed salim ch3
Digital logic mohammed salim ch3
 
review of number systems and codes
review of number systems and codesreview of number systems and codes
review of number systems and codes
 
EMBEDDED SYSTEMS 6
EMBEDDED SYSTEMS 6EMBEDDED SYSTEMS 6
EMBEDDED SYSTEMS 6
 
ENGR 312 Wind Power
ENGR 312   Wind PowerENGR 312   Wind Power
ENGR 312 Wind Power
 
Binary addition
Binary additionBinary addition
Binary addition
 
Telecommunication Network 1
Telecommunication Network 1Telecommunication Network 1
Telecommunication Network 1
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
 
Digital logic mohammed salim ch2
Digital logic mohammed salim ch2Digital logic mohammed salim ch2
Digital logic mohammed salim ch2
 

Similar to 2s complement arithmetic

2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
Sathishkumar.V
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
MeghadriGhosh4
 
2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt
nashitahalwaz95
 
Alu1
Alu1Alu1
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
Meenakshi Paul
 
UNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhgghUNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhggh
KwadjoOwusuAnsahQuar
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
NabeelaNousheen
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
arunachalamr16
 
data representation
 data representation data representation
data representation
Haroon_007
 
Data representation notes class 11
Data representation notes class 11Data representation notes class 11
Data representation notes class 11
ShresthMaurya1
 
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
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
MtikuTadesse
 
computer architecture organization in Ece
computer architecture organization in Ececomputer architecture organization in Ece
computer architecture organization in Ece
Bayesayohannis
 
Computer arithmetic operations.pptx
Computer arithmetic operations.pptxComputer arithmetic operations.pptx
Computer arithmetic operations.pptx
ssusera6fdd5
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
zorogoh2
 
1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx
LibanMohamed26
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
TamiratDejene1
 
lect1.ppt
lect1.pptlect1.ppt
lect1.ppt
MarlonMagtibay2
 
DATA REPRESENTATION.pptx
DATA REPRESENTATION.pptxDATA REPRESENTATION.pptx
DATA REPRESENTATION.pptx
MamataAnilgod
 

Similar to 2s complement arithmetic (20)

2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
 
2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt
 
Alu1
Alu1Alu1
Alu1
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
UNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhgghUNIT 4 -Data Representation.pptxfghfghhggh
UNIT 4 -Data Representation.pptxfghfghhggh
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
data representation
 data representation data representation
data representation
 
Data representation notes class 11
Data representation notes class 11Data representation notes class 11
Data representation notes class 11
 
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...
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
 
computer architecture organization in Ece
computer architecture organization in Ececomputer architecture organization in Ece
computer architecture organization in Ece
 
DCF QNA edited
DCF QNA editedDCF QNA edited
DCF QNA edited
 
Computer arithmetic operations.pptx
Computer arithmetic operations.pptxComputer arithmetic operations.pptx
Computer arithmetic operations.pptx
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
lect1.ppt
lect1.pptlect1.ppt
lect1.ppt
 
DATA REPRESENTATION.pptx
DATA REPRESENTATION.pptxDATA REPRESENTATION.pptx
DATA REPRESENTATION.pptx
 

More from Sanjay Saluth

Mettalurgy & heat treatment
Mettalurgy & heat treatmentMettalurgy & heat treatment
Mettalurgy & heat treatmentSanjay Saluth
 
Boss (Indian) Window
Boss (Indian) WindowBoss (Indian) Window
Boss (Indian) WindowSanjay Saluth
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
Sanjay Saluth
 
Yamaha Manufacturing Plant
Yamaha Manufacturing PlantYamaha Manufacturing Plant
Yamaha Manufacturing Plant
Sanjay Saluth
 
Online Railway Reservation System
Online Railway Reservation SystemOnline Railway Reservation System
Online Railway Reservation System
Sanjay Saluth
 
Direct Memory Access
Direct Memory AccessDirect Memory Access
Direct Memory Access
Sanjay Saluth
 

More from Sanjay Saluth (6)

Mettalurgy & heat treatment
Mettalurgy & heat treatmentMettalurgy & heat treatment
Mettalurgy & heat treatment
 
Boss (Indian) Window
Boss (Indian) WindowBoss (Indian) Window
Boss (Indian) Window
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
Yamaha Manufacturing Plant
Yamaha Manufacturing PlantYamaha Manufacturing Plant
Yamaha Manufacturing Plant
 
Online Railway Reservation System
Online Railway Reservation SystemOnline Railway Reservation System
Online Railway Reservation System
 
Direct Memory Access
Direct Memory AccessDirect Memory Access
Direct Memory Access
 

Recently uploaded

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 

Recently uploaded (20)

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 

2s complement arithmetic

  • 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 fixedlength 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, 8bits, 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. 999 forward (+) 998 997 001 000 999 998 002 001 backward (-) 5
  • 6. Negative Decimal How do we represent negative numbers in this 3digit decimal number system without using a sign? +499 499 +498 498 +497 497 Cut the number system in half. +001 001 Use 001 – 499 to indicate positive numbers. 000 000 -001 999 -002 998 -499 501 -500 500 Use 500 – 999 to indicate negative numbers. Notice that 000 is not positive or negative. pos(+) neg(-) 6
  • 7. “Odometer” Math Examples 3 + 2 5 003 + 002 005 6 + (-3) 006 + 997 3 1]003 (-5) + 2 995 + 002 (-2) + (-3) 998 + 997 (-3) 997 (-5) 1]995 It Works! Disregard Overflow Disregard Overflow 7
  • 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 Example #1 -003 ↓↓↓ 996 +1 997 Complement Digits Add 1 Example #2 -214 ↓↓↓ 785 +1 786 Complement Digits Add 1 10
  • 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? Use 00000001 – 01111111 to indicate positive numbers. Use 10000000 – 11111111 to indicate negative numbers. Notice that 00000000 is not positive or negative. 01111111 +126 01111110 +125 01111101 +1 00000001 0 00000000 -1 11111111 -2 Cut the number system in half. +127 11111110 -127 10000001 -128 10000000 pos(+) neg(-) 11
  • 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. +127 01111111 +126 01111110 +125 01111101 +1 00000001 The MSB is (1) for all negative numbers. 0 00000000 -1 11111111 • The MSB is called the sign bit. -2 11111110 • In a signed number system, this allows you to instantly determine whether a number is positive or negative. -127 10000001 -128 10000000 pos(+) neg(-) 12
  • 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 Example #1 5 = 00000101 ↓↓↓↓↓↓↓↓ 11111010 +1 Complement Digits Add 1 -5 = 11111011 Example #2 -13 = 11110011 ↓↓↓↓↓↓↓↓ 00001100 +1 13 = 00001101 Complement Digits Add 1 14
  • 15. Using The 2’s Compliment Process Use the 2’s complement process to add together the following numbers. POS + POS POS 9 ⇒+ 5 14 NEG + POS NEG ⇒ POS + NEG POS 9 ⇒ + (-5) 4 NEG + NEG NEG (-9) ⇒ + (-5) - 14 (-9) + 5 -4 15
  • 16. POS + POS → POS Answer If no 2’s complement is needed, use regular binary addition. 9 + 5 14 → → 00001001 + 00000101 ← 00001110 16
  • 17. POS + NEG → POS Answer Take the 2’s complement of the negative number and use regular binary addition. 9 + (-5) 4 → ← 00001001 + 11111011 1]00000100 8th Bit = 0: Answer is Positive Disregard 9th Bit 00000101 ↓↓↓↓↓↓↓↓ 11111010 +1 11111011 2’s Complement Process 17
  • 18. POS + NEG → NEG Answer Take the 2’s complement of the negative number and use regular binary addition. (-9) + 5 -4 → ← 11110111 + 00000101 11111100 8th Bit = 1: Answer is Negative To Check: Perform 2’s Complement On Answer 11111100 ↓↓↓↓↓↓↓↓ 00000011 +1 00000100 00001001 ↓↓↓↓↓↓↓↓ 11110110 +1 11110111 2’s Complement Process 18
  • 19. NEG + NEG → NEG Answer Take the 2’s complement of both negative numbers and use regular binary addition. (-9) + (-5) -14 → → ← 11110111 + 11111011 1]11110010 2’s Complement Numbers, See Conversion Process In Previous Slides 8th Bit = 1: Answer is Negative Disregard 9th Bit To Check: Perform 2’s Complement On Answer 11110010 ↓↓↓↓↓↓↓↓ 00001101 +1 00001110 19

Editor's Notes

  1. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  2. Introductory Slide / Overview of Presentation 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  3. This slide explains the need to negative number and why we don’t have subtract-er circuits. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  4. This slide explains why we need a way to represent negative numbers. It introduces the concept of a fixed-length number system. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  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. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  6. This slide explains how to represent negative numbers in a fix-length decimal number system. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  7. Here are four example of adding two numbers in the odometer number system (i.e., 3-digit decimal number system). 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  8. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  9. This slide describes the 10’s complement conversion process. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  10. Examples of the 10’s Complement Process. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  11. Introduction to the 8-Bit Binary Number system and how negative numbers are represented. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  12. Explanation of the sign bit. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  13. This slide describes the 2’s complement conversion process. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  14. Examples of the 2’s Complement Process. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  15. 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. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  16. Addition of two Positive numbers. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  17. 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. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  18. 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. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009
  19. This slide demonstrates the addition of two negative numbers. 2's Complement Arithmetic Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics Project Lead The Way, Inc. Copyright 2009