SlideShare a Scribd company logo
Complements
digital electronics - 13IDP1413IDP14
Subtraction using addition
 Conventional addition (using carry) is easily
 implemented in digital computers.
 However; subtraction by borrowing is difficult
and inefficient for digital computers.
 Much more efficient to implement subtraction
using ADDITION OF the COMPLEMENTS of
numbers.
Complements of numbers
(r-1 )’s Complement
•Given a number N in base r having n digits,
•the (r- 1)’s complement of N is defined as
(rn
- 1) - N
•For decimal numbers the
base or r = 10 and r- 1= 9,
•so the 9’s complement of N is
(10n
-1)-N
•99999……. - N
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
9 9 9 9 9
-
2- Find the 9’s complement of 546700 and 12389
The 9’s complement of 546700 is 999999 - 546700=
453299
and the 9’s complement of 12389 is
99999- 12389 = 87610.
9’s complement Examples
5 4 6 7 0- 0
9 9 9 9 9 9
4 5 3 2 9 9
1 2 3 8- 9
9 9 9 9 9
8 7 6 1 0
l’s complement
 For binary numbers, r = 2 and r — 1 =
1,
 r-1’s complement is the l’s complement.
 The l’s complement of N is (2n - 1) - N.
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
1 1 1 1 1
Bit n-1 Bit n-2 ……. Bit 1 Bit 0
-
l’s complement
Find r-1 complement for binary number N with four binary digits.
r-1 complement for binary means 2-1 complement or 1’s complement.
n = 4, we have 24
= (10000)2
and 24
- 1 = (1111)2
.
The l’s complement of N is (24
- 1) - N. = (1111) - N
The complement 1’s of
1011001 is 0100110
0 1 1 0 0- 1
1 1 1 1 1 1
1 0 0 1 1 0
0 0 1 1 1- 1
1 1 1 1 1 1
1 1 0 0 0 0
1
1
0
The 1’s complement of
0001111 is 1110000
0
1
1
l’s complement
r’s Complement
•Given a number N in base r having n digits,
•the r’s complement of N is defined as
rn
- N.
•For decimal numbers the
base or r = 10,
•so the 10’s complement of N
is 10n
-N.
•100000……. - N
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
0 0 0 0 0
-
1
10’s complement Examples
Find the 10’s complement of
546700 and 12389
The 10’s complement of 546700
is 1000000 - 546700= 453300
and the 10’s complement of
12389 is
100000 - 12389 = 87611.
Notice that it is the same as 9’s
complement + 1.
5 4 6 7 0- 0
0 0 0 0 0 0
4 5 3 3 0 0
1 2 3 8- 9
1 0 0 0 0 0
8 7 6 1 1
1
For binary numbers, r = 2,
r’s complement is the 2’s complement.
The 2’s complement of N is 2n
- N.
2’s complement
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
0 0 0 0 0
-
1
2’s complement Example
The 2’s complement of
1011001 is 0100111
The 2’s complement of
0001111 is 1110001
0 1 1 0 0- 1
0 0 0 0 0 0
1 0 0 1 1 1
0 0 1 1 1- 1
1 1 0 0 0 1
1
0
0
0
1
1
0 0 0 0 0 001
Fast Methods for 2’s
Complement
Method 1:
The 2’s complement of binary number is obtained by adding 1 to the
l’s complement value.
Example:
1’s complement of 101100 is 010011 (invert the 0’s and 1’s)
2’s complement of 101100 is 010011 + 1 = 010100
Fast Methods for 2’s
Complement
Method 2:
The 2’s complement can be formed by leaving all least significant 0’s
and the first 1 unchanged, and then replacing l’s by 0’s and 0’s by l’s
in all other higher significant bits.
Example:
The 2’s complement of 1101100 is
0010100
Leave the two low-order 0’s and the first 1 unchanged, and then
replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.
Examples
– Finding the 2’s complement of (01100101)2
• Method 1 – Simply complement each bit and then
add 1 to the result.
(01100101)2
[N] = 2’s complement = 1’s complement (10011010)2 +1
=(10011011)2
• Method 2 – Starting with the least significant bit,
copy all the bits up to and including the first 1 bit
and then complement the remaining bits.
N = 0 1 1 0 0 1 0 1
[N] = 1 0 0 1 1 0 1 1
Subtraction of Unsigned
Numbers
using r’s complement
Subtract N from M : M – N
 r’s complement N  (rn – N )
 add M to ( rn – N ) : Sum = M + ( r n – N)
  take r’s complement (If M ≥ N, the negative
sign will produce an end carry  rn we need
to take the r’s complement again.)
Subtraction of Unsigned
Numbers
using r’s complement
 (1) if M ≥ N, ignore the carry without
taking complement of sum.
 (2) if M < N, take the r’s complement of
sum and place negative sign in front of
sum. The answer is negative.
Example 1 (Decimal unsigned numbers),
perform the subtraction 72532 - 13250 = 59282.
M > N : “Case 1” “Do not take complement of sum
and discard carry”
The 10’s complement of 13250 is 86750.
Therefore:
M = 72532
10’s complement of N =+86750
Sum= 159282
Discard end carry 105
= - 100000
Answer = 59282 no complement
Example 2;
Now consider an example with M <N.
The subtraction 13250 - 72532 produces negative 59282. Using
the procedure with complements, we have
M = 13250
10’s complement of N = +27468
Sum = 40718
Take 10’s complement of Sum = 100000
-40718
The number is : 59282
Place negative sign in front of the number: -59282

More Related Content

What's hot

Error Detection and Correction presentation
Error Detection and Correction presentation Error Detection and Correction presentation
Error Detection and Correction presentation
Badrul Alam
 
13 Boolean Algebra
13 Boolean Algebra13 Boolean Algebra
13 Boolean Algebra
Praveen M Jigajinni
 
K - Map
  K - Map    K - Map
K - Map
Abhishek Choksi
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbers
Kiriti Varkur
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
shahzad ali
 
Encoder & Decoder
Encoder & DecoderEncoder & Decoder
Encoder & Decoder
Syed Saeed
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
pyingkodi maran
 
Combinational circuits
Combinational circuits Combinational circuits
Combinational circuits
DrSonali Vyas
 
Sequential Logic Circuit
Sequential Logic CircuitSequential Logic Circuit
Sequential Logic Circuit
Ramasubbu .P
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
SnehalataAgasti
 
Complement
ComplementComplement
Complement
Sudheesh S Madhav
 
Array ppt
Array pptArray ppt
Array ppt
Kaushal Mehta
 
Binary codes
Binary codesBinary codes
Binary codes
GargiKhanna1
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
Neeru Mittal
 
compliments
 compliments compliments
compliments
Unsa Shakir
 
Timing and control
Timing and controlTiming and control
Timing and control
chauhankapil
 
Check sum
Check sumCheck sum
Check sum
Pooja Jaiswal
 
Stack organization
Stack organizationStack organization
Stack organization
chauhankapil
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
Revathi Subramaniam
 

What's hot (20)

Error Detection and Correction presentation
Error Detection and Correction presentation Error Detection and Correction presentation
Error Detection and Correction presentation
 
13 Boolean Algebra
13 Boolean Algebra13 Boolean Algebra
13 Boolean Algebra
 
K - Map
  K - Map    K - Map
K - Map
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbers
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
 
Encoder & Decoder
Encoder & DecoderEncoder & Decoder
Encoder & Decoder
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Combinational circuits
Combinational circuits Combinational circuits
Combinational circuits
 
Sequential Logic Circuit
Sequential Logic CircuitSequential Logic Circuit
Sequential Logic Circuit
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
 
Complement
ComplementComplement
Complement
 
Array ppt
Array pptArray ppt
Array ppt
 
Binary codes
Binary codesBinary codes
Binary codes
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
compliments
 compliments compliments
compliments
 
Timing and control
Timing and controlTiming and control
Timing and control
 
Check sum
Check sumCheck sum
Check sum
 
Stack organization
Stack organizationStack organization
Stack organization
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
 

Viewers also liked

1s and 2s complement
1s and 2s complement1s and 2s complement
1s and 2s complement
Then Murugeshwari
 
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
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
mayannpolisticoLNU
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
Sanjay Saluth
 
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
 
Introduction number systems and conversion
 Introduction number systems and conversion Introduction number systems and conversion
Introduction number systems and conversionkanyuma jitjumnong
 
Number System
Number SystemNumber System
Number System
samarthagrawal
 
Multiplication The Complement Method
Multiplication   The Complement MethodMultiplication   The Complement Method
Multiplication The Complement Method
PuworkUtara OnSlideshare
 
Digital logic mohammed salim ch3
Digital logic mohammed salim ch3Digital logic mohammed salim ch3
Digital logic mohammed salim ch3
Asst Lect Mohammed Salim
 
Digital logic mohammed salim ch2
Digital logic mohammed salim ch2Digital logic mohammed salim ch2
Digital logic mohammed salim ch2
Asst Lect Mohammed Salim
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
Learn By Watch
 
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Vitthal Jadhav
 
How to perform well in a job interview
How to perform well in a job interviewHow to perform well in a job interview
How to perform well in a job interview
Tien Nguyen Thanh
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
United International University
 

Viewers also liked (20)

1s and 2s complement
1s and 2s complement1s and 2s complement
1s and 2s 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
 
2's complement
2's complement2's complement
2's complement
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
 
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
 
Introduction number systems and conversion
 Introduction number systems and conversion Introduction number systems and conversion
Introduction number systems and conversion
 
Number System
Number SystemNumber System
Number System
 
Multiplication The Complement Method
Multiplication   The Complement MethodMultiplication   The Complement Method
Multiplication The Complement Method
 
Stld
StldStld
Stld
 
Digital logic mohammed salim ch3
Digital logic mohammed salim ch3Digital logic mohammed salim ch3
Digital logic mohammed salim ch3
 
Digital logic mohammed salim ch2
Digital logic mohammed salim ch2Digital logic mohammed salim ch2
Digital logic mohammed salim ch2
 
Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)
 
DLD Intro
DLD IntroDLD Intro
DLD Intro
 
Main Memory
Main MemoryMain Memory
Main Memory
 
How to perform well in a job interview
How to perform well in a job interviewHow to perform well in a job interview
How to perform well in a job interview
 
OS - Thread
OS - ThreadOS - Thread
OS - Thread
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
 

Similar to Complements

Dld lecture module 02
Dld lecture module 02Dld lecture module 02
Dld lecture module 02
Bilal Maqbool ツ
 
Digital logic and design 02
Digital logic and design 02Digital logic and design 02
Digital logic and design 02
ranjit shrestha
 
Lecture_5-2.ppt
Lecture_5-2.pptLecture_5-2.ppt
Lecture_5-2.ppt
MeghadriGhosh4
 
B sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemB sc cs i bo-de u-i number system
B sc cs i bo-de u-i number system
Rai University
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
Rai University
 
Lecture 09
Lecture 09Lecture 09
Lecture 09
sohelranasweet
 
unit-2_DL.pdf
unit-2_DL.pdfunit-2_DL.pdf
unit-2_DL.pdf
ashoksahu64
 
B.sc cs-ii-u-1.3 digital logic circuits, digital component
B.sc cs-ii-u-1.3 digital logic circuits, digital componentB.sc cs-ii-u-1.3 digital logic circuits, digital component
B.sc cs-ii-u-1.3 digital logic circuits, digital component
Rai University
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of informationRoma Kimberly Erolin
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of informationRoma Kimberly Erolin
 
Number system
Number systemNumber system
Number system
Mantra VLSI
 
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
shubhamgupta7133
 
Bca 2nd sem-u-1.3 digital logic circuits, digital component
Bca 2nd sem-u-1.3 digital logic circuits, digital componentBca 2nd sem-u-1.3 digital logic circuits, digital component
Bca 2nd sem-u-1.3 digital logic circuits, digital component
Rai University
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
Mohammad Bashartullah
 
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
MahiboobAliMulla
 
Complement
ComplementComplement
Complement
Bilal Maqbool ツ
 
Data r epresentation
Data r epresentationData r epresentation
Data r epresentation
Sanjeev Patel
 
B sc3 unit 2 number system
B sc3  unit 2 number systemB sc3  unit 2 number system
B sc3 unit 2 number system
MahiboobAliMulla
 

Similar to Complements (20)

Good
GoodGood
Good
 
Dld lecture module 02
Dld lecture module 02Dld lecture module 02
Dld lecture module 02
 
Digital logic and design 02
Digital logic and design 02Digital logic and design 02
Digital logic and design 02
 
Lecture_5-2.ppt
Lecture_5-2.pptLecture_5-2.ppt
Lecture_5-2.ppt
 
B sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemB sc cs i bo-de u-i number system
B sc cs i bo-de u-i number system
 
Lec20
Lec20Lec20
Lec20
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
 
Lecture 09
Lecture 09Lecture 09
Lecture 09
 
unit-2_DL.pdf
unit-2_DL.pdfunit-2_DL.pdf
unit-2_DL.pdf
 
B.sc cs-ii-u-1.3 digital logic circuits, digital component
B.sc cs-ii-u-1.3 digital logic circuits, digital componentB.sc cs-ii-u-1.3 digital logic circuits, digital component
B.sc cs-ii-u-1.3 digital logic circuits, digital component
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of information
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of information
 
Number system
Number systemNumber system
Number system
 
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
 
Bca 2nd sem-u-1.3 digital logic circuits, digital component
Bca 2nd sem-u-1.3 digital logic circuits, digital componentBca 2nd sem-u-1.3 digital logic circuits, digital component
Bca 2nd sem-u-1.3 digital logic circuits, digital component
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
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
 
Complement
ComplementComplement
Complement
 
Data r epresentation
Data r epresentationData r epresentation
Data r epresentation
 
B sc3 unit 2 number system
B sc3  unit 2 number systemB sc3  unit 2 number system
B sc3 unit 2 number system
 

Recently uploaded

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

Complements

  • 2. Subtraction using addition  Conventional addition (using carry) is easily  implemented in digital computers.  However; subtraction by borrowing is difficult and inefficient for digital computers.  Much more efficient to implement subtraction using ADDITION OF the COMPLEMENTS of numbers.
  • 3. Complements of numbers (r-1 )’s Complement •Given a number N in base r having n digits, •the (r- 1)’s complement of N is defined as (rn - 1) - N •For decimal numbers the base or r = 10 and r- 1= 9, •so the 9’s complement of N is (10n -1)-N •99999……. - N Digit n Digit n-1 Next digit Next digit First digit 9 9 9 9 9 -
  • 4. 2- Find the 9’s complement of 546700 and 12389 The 9’s complement of 546700 is 999999 - 546700= 453299 and the 9’s complement of 12389 is 99999- 12389 = 87610. 9’s complement Examples 5 4 6 7 0- 0 9 9 9 9 9 9 4 5 3 2 9 9 1 2 3 8- 9 9 9 9 9 9 8 7 6 1 0
  • 5. l’s complement  For binary numbers, r = 2 and r — 1 = 1,  r-1’s complement is the l’s complement.  The l’s complement of N is (2n - 1) - N. Digit n Digit n-1 Next digit Next digit First digit 1 1 1 1 1 Bit n-1 Bit n-2 ……. Bit 1 Bit 0 -
  • 6. l’s complement Find r-1 complement for binary number N with four binary digits. r-1 complement for binary means 2-1 complement or 1’s complement. n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2 . The l’s complement of N is (24 - 1) - N. = (1111) - N
  • 7. The complement 1’s of 1011001 is 0100110 0 1 1 0 0- 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1- 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 The 1’s complement of 0001111 is 1110000 0 1 1 l’s complement
  • 8. r’s Complement •Given a number N in base r having n digits, •the r’s complement of N is defined as rn - N. •For decimal numbers the base or r = 10, •so the 10’s complement of N is 10n -N. •100000……. - N Digit n Digit n-1 Next digit Next digit First digit 0 0 0 0 0 - 1
  • 9. 10’s complement Examples Find the 10’s complement of 546700 and 12389 The 10’s complement of 546700 is 1000000 - 546700= 453300 and the 10’s complement of 12389 is 100000 - 12389 = 87611. Notice that it is the same as 9’s complement + 1. 5 4 6 7 0- 0 0 0 0 0 0 0 4 5 3 3 0 0 1 2 3 8- 9 1 0 0 0 0 0 8 7 6 1 1 1
  • 10. For binary numbers, r = 2, r’s complement is the 2’s complement. The 2’s complement of N is 2n - N. 2’s complement Digit n Digit n-1 Next digit Next digit First digit 0 0 0 0 0 - 1
  • 11. 2’s complement Example The 2’s complement of 1011001 is 0100111 The 2’s complement of 0001111 is 1110001 0 1 1 0 0- 1 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 1 1- 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 001
  • 12. Fast Methods for 2’s Complement Method 1: The 2’s complement of binary number is obtained by adding 1 to the l’s complement value. Example: 1’s complement of 101100 is 010011 (invert the 0’s and 1’s) 2’s complement of 101100 is 010011 + 1 = 010100
  • 13. Fast Methods for 2’s Complement Method 2: The 2’s complement can be formed by leaving all least significant 0’s and the first 1 unchanged, and then replacing l’s by 0’s and 0’s by l’s in all other higher significant bits. Example: The 2’s complement of 1101100 is 0010100 Leave the two low-order 0’s and the first 1 unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.
  • 14. Examples – Finding the 2’s complement of (01100101)2 • Method 1 – Simply complement each bit and then add 1 to the result. (01100101)2 [N] = 2’s complement = 1’s complement (10011010)2 +1 =(10011011)2 • Method 2 – Starting with the least significant bit, copy all the bits up to and including the first 1 bit and then complement the remaining bits. N = 0 1 1 0 0 1 0 1 [N] = 1 0 0 1 1 0 1 1
  • 15. Subtraction of Unsigned Numbers using r’s complement Subtract N from M : M – N  r’s complement N  (rn – N )  add M to ( rn – N ) : Sum = M + ( r n – N)   take r’s complement (If M ≥ N, the negative sign will produce an end carry  rn we need to take the r’s complement again.)
  • 16. Subtraction of Unsigned Numbers using r’s complement  (1) if M ≥ N, ignore the carry without taking complement of sum.  (2) if M < N, take the r’s complement of sum and place negative sign in front of sum. The answer is negative.
  • 17. Example 1 (Decimal unsigned numbers), perform the subtraction 72532 - 13250 = 59282. M > N : “Case 1” “Do not take complement of sum and discard carry” The 10’s complement of 13250 is 86750. Therefore: M = 72532 10’s complement of N =+86750 Sum= 159282 Discard end carry 105 = - 100000 Answer = 59282 no complement
  • 18. Example 2; Now consider an example with M <N. The subtraction 13250 - 72532 produces negative 59282. Using the procedure with complements, we have M = 13250 10’s complement of N = +27468 Sum = 40718 Take 10’s complement of Sum = 100000 -40718 The number is : 59282 Place negative sign in front of the number: -59282