SlideShare a Scribd company logo
1 of 14
Download to read offline
3/28/2012
1
Digital Logic & Design
Dr. Sajjad Ahmed Nadeem
Department of Computer Science & IT
University of Azad Jammu & Kashmir
Muzaffarabad
Module 02_01
Complements.
The (r-1)’s Complement.
The r’s Complement.
Subtraction with Complements.
3/28/2012
2
Complements (1)
Used in digital computers for
◦ simplifying the subtraction operation
◦ logical manipulations.
There are two types of complements for each base-r
system:
1. The (r – 1)’s Complement (Diminished radix complement).
2. The r’s Complement (Radix complement).
For Decimal numbers we have 9’s and 10’s complement
For Binary numbers we have 1’s and 2’s complement
Complements (2)
Complements of numbers with fractions
1. Remove the radix point
2. Obtain the complement
3. Return the radix point to its position
3/28/2012
3
The (r – 1)’s Complement (1)
Let X be a positive number in base r with n
digits, the (r – 1)’s complement of X is defined
as
(rⁿ - 1) – X
For r=10, it is called 9’s complement and
is given by (10ⁿ - 1) – X
For r=2, it is called 1’s complement and is
given by (2ⁿ - 1) – X
The (r – 1)’s Complement (2)
The 9’s complement of (52520)10 is
{(105 – 1) – 52520} = 99999 – 52520 = 47479.
The 9’s complement of (0.3267)10 is
{(104 – 1) – 3267} = 9999 – 3267 = 6732.
(Answer is 0.6732.)
The 9’s complement of (25.639)10 is
(105– 1– 25639) = 99999 – 25639 = 74360.
(Answer is 74.360.)
3/28/2012
4
The (r – 1)’s Complement (3)
The 1’s complement of (101100)2 is
(26 – 1) 10 – (101100)2 = (111111 – 101100)2 =
010011.
The 1’s complement of (0.0110)2 is
(24 – 1)10 – (0110)2 = (1111 – 0110)2 = 1001.
(Answer is 0.1001)
The 1’s complement of (100.0110)2 is
(27 – 1)10 – (1000110)2 = (1111111 –
1000110)2 = 0111001.
(Answer is 011.1001)
The (r – 1)’s Complement (4)
The 9’s complement of a decimal number
is formed simply by subtracting every digit
from 9.
The 1’s complement of a binary number is
simpler to form: the 1’s are changed to 0’s
and 0’s to 1’s.
3/28/2012
5
The r’s Complement (1)
Let X be a positive number in base r with n
digits, the r’s complement of X is defined as
rⁿ – X for X ≠ 0
0 for X = 0
For r=10, it is called 10’s complement and
is given by 10ⁿ – X = (10ⁿ – 1) – X + 1
For r=2, it is called 2’s complement and is
given by 2ⁿ – X = (2ⁿ – 1) – X + 1
The r’s Complement (1)
The 10’s complement of (52520)10 is
(105 – 1) – 52520 + 1 = 47480.
(The number of digits in the number is n=5.)
The 10’s complement of (0.3267)10 is
(104 – 1) – 3267 + 1 = 6733
(Answer is 0.6733)
The 10’s complement of (25.639)10 is
(105 – 1) – 25639 + 1= 74361
(Answer is 74.361)
3/28/2012
6
The r’s Complement (2)
The 2’s Complement of (101100)2 is
{(26 – 1)10 – (101100)2 }+ 1
= (111111 – 101100)+1
= 010100.
The 2’s Complement of (0.0110)2 is
{(24 – 1)10 – (0110)2 }+ 1
= 1010.
(Answer is 0.1010)
The r’s Complement (3)
10’s complement can be formed by
◦ leaving all least significant zeros unchanged and
◦ then subtracting the first non-zero least significant
digit from 10, and
◦ then subtracting all other higher significant digits from
9.
The 2’s Complement can be formed by
◦ leaving all least significant zeros and first non zero
digit unchanged, and
◦ then replacing 1’s by 0’s and 0’s by 1’s in all other
higher significant digits.
3/28/2012
7
Complement of Complement
The complement of complement restores
the number to its original value.
The r’s complement of N is rⁿ - N.
Therefore, the complement of (rⁿ - N) is
rⁿ - (rⁿ - N)
= N
Subtraction with r’s compliment (1)
The subtraction of two positive numbers (M – N), both
of base r, may be done as follows.
1. Add the minuend M to the r’s complement of
subtrahend N.
M – N =M+ r’s complement (N)
2. Inspect the result obtained in step 1 for an end carry:
(a) If an end carry occurs discard it.
(b) If an end carry does not occur, take the r’s
complement of the number obtained in step 1, and
place a negative sign in front.
3/28/2012
8
Subtraction with r’s compliment (2)
Using 10’s complement,subtract 72532 – 3250.
M = 72532 , N = 03250.
10’s complement of subtrahend N = 96750.
Step 1: 72532
+ 96750
End Carry 1 69282
Step 2, discard carry.
Answer = 69282.
Subtraction with r’s compliment (3)
Subtract: (3250 – 72532)10
M = 03250,N = 72532.
10’s complement of N = 27468.
Step 1: 03250
+ 27468
30718 (No End Carry)
Step 2:Answer = - (10’s complement of 30718)
Answer = - 69282
3/28/2012
9
Subtraction with r’s compliment (4)
Using 2’s complement, subtract 1010100 –
1000100.
M = 1010100,N = 1000100.
2’s complement of N = 0111100
Step 1: 1010100
+ 0111100
End Carry 1 0010000
Step 2: Discard Carry.
Answer = 0010000
Subtraction with r’s compliment (5)
Using 2’s complement, subtract 1000100 –
1010100.
M = 1000100,N = 1010100.
2’s complement of N = 0101100
Step 1: 1000100
+ 0101100
No Carry 1110000
Step 2:Answer = - (2’s complement of 1110000)
Answer = - 0010000
3/28/2012
10
Subtraction with (r – 1)’s compliment (1)
The procedure for subtraction with the (r – 1)’s
complement is exactly the same as the one used with r’s
compliment except for one variation, called “end-round
carry”.
The subtraction of two positive numbers (M – N), both of
base r, may be done as follows.
1. Add the minuend M to the (r – 1)’s complement of the
subtrahend N.
M – N =M+ (r – 1)’s complement (N)
2. Inspect the result obtained in step 1 for an End carry.
(a) If an end carry occurs, add 1 to the least significant
digit ( end-around carry).
(b) If an end carry does not occur, take the (r – 1)’s
complement of the number obtained in step 1 and place
a negative sign in front.
Using 9’s complement, subtract 72532 – 3250.
M = 72532 , N = 03250.
9’s complement of subtrahend N = 96749.
Step 1: 72532
+ 96749
End-around Carry 1 69281
Step 2,add end around carry. + 1
Answer = 69282
Subtraction with (r – 1)’s compliment (2)
3/28/2012
11
Subtract: (3250 – 72532)10
M = 03250,N = 72532.
9’s complement of N = 27467.
Step 1: 03250
+ 27467
30717 (No End Carry)
Step 2:Answer = - (9’s complement of 30717)
Answer = - 69282
Subtraction with (r – 1)’s compliment (3)
Using 1’s complement, subtract 1010100 –
1000100.
M = 1010100,N = 1000100.
1’s complement of N = 0111011
Step 1: 1010100
+ 0111011
End Carry 1 0001111
Step 2 + 1
Answer = 0010000
Subtraction with (r – 1)’s compliment (4)
3/28/2012
12
Using 1’s complement, subtract 1000100 –
1010100.
M = 1000100,N = 1010100.
1’s complement of N = 0101011
Step 1: 1000100
+ 0101011
No Carry 1101111
Step 2:Answer = - (1’s complement of 1101111)
Answer = - 10000
Subtraction with (r – 1)’s compliment (5)
Signed Binary Numbers (1)
We have one way to represent a positive number
(say +9)
Three ways to represent a negative numbers (say -9)
Sign Bit
◦ Signed-magnitude representation 1 0001001
◦ Signed-1’s complement representation 1 1110110
◦ Signed-2’s complement representation 1 1110111
3/28/2012
13
Signed Binary Numbers (2)
Signed Binary Numbers-Addition
Addition of two numbers in signed magnitude system
follow the same rules of ordinary arithmatic.
The addition of two signed binary numbers
◦ Use binary representation of the numbers and add them
◦ In case of negative number, add the 2’s complement of the negative
number to the positive number alongwith sign bits
◦ Add the 2’s complement of the negative numbers
◦ A carry out of the sign bit position is discarded
◦ If the sum obtained is in negative it is automatically in 2’s
complement form.
3/28/2012
14
Signed Binary Numbers-Subtraction
Take the 2’s complement of the subtrahed (including the
sign bit)
Add the obtained 2’s complement to the minuend
(including the sign bit).
A carry out of sign bit is discarded
Assignment
r’s complement for octal & hexadecimal
(r-1)’s complement for octal &
hexadecimal
Comparison between 1’s and 2’s
Complement.

More Related Content

What's hot (20)

Array in c++
Array in c++Array in c++
Array in c++
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Tree (Data Structure & Discrete Mathematics)
Tree (Data Structure & Discrete Mathematics)Tree (Data Structure & Discrete Mathematics)
Tree (Data Structure & Discrete Mathematics)
 
Trees and graphs
Trees and graphsTrees and graphs
Trees and graphs
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
 
Division algorithm
Division algorithmDivision algorithm
Division algorithm
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recoding
 
11 octal number system
11   octal number system11   octal number system
11 octal number system
 
Adder Presentation
Adder PresentationAdder Presentation
Adder Presentation
 
Binary codes
Binary codesBinary codes
Binary codes
 
What is bcd number system
What is bcd number systemWhat is bcd number system
What is bcd number system
 
Array ppt
Array pptArray ppt
Array ppt
 
Number System
Number SystemNumber System
Number System
 
KMAP
KMAPKMAP
KMAP
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Data structure tree - intermediate
Data structure tree - intermediateData structure tree - intermediate
Data structure tree - intermediate
 
Half adder and full adder
Half adder and full adderHalf adder and full adder
Half adder and full adder
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis
 
Chapter 1: Binary System
 Chapter 1: Binary System Chapter 1: Binary System
Chapter 1: Binary System
 

Viewers also liked (20)

Dld lecture module 01
Dld lecture module 01Dld lecture module 01
Dld lecture module 01
 
Basic+machine+organization
Basic+machine+organizationBasic+machine+organization
Basic+machine+organization
 
English 01 application
English 01 applicationEnglish 01 application
English 01 application
 
Number+system (1)
Number+system (1)Number+system (1)
Number+system (1)
 
Dld lecture module 06
Dld lecture module 06Dld lecture module 06
Dld lecture module 06
 
Graphical programming
Graphical programmingGraphical programming
Graphical programming
 
Uncdtalk
UncdtalkUncdtalk
Uncdtalk
 
Dld lecture module 03
Dld lecture module 03Dld lecture module 03
Dld lecture module 03
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
Chapter10
Chapter10Chapter10
Chapter10
 
Complement
ComplementComplement
Complement
 
Dld lecture module 05
Dld lecture module 05Dld lecture module 05
Dld lecture module 05
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
 
Good
GoodGood
Good
 
Dld lecture module 04 01
Dld lecture module 04  01Dld lecture module 04  01
Dld lecture module 04 01
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Internet
InternetInternet
Internet
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
An introduction to software
An introduction to softwareAn introduction to software
An introduction to software
 

Similar to Dld lecture module 02

Digital logic and design 02
Digital logic and design 02Digital logic and design 02
Digital logic and design 02ranjit shrestha
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbersKiriti Varkur
 
Number System 123.ppt is for binary number system
Number System 123.ppt is for binary number systemNumber System 123.ppt is for binary number system
Number System 123.ppt is for binary number systemdrpreetiwctm
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxSurendra Loya
 
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 systemRai University
 
Application of bases
Application of basesApplication of bases
Application of basesAbdur Rehman
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptDavid Louie Bedia
 
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 fieldshubhamgupta7133
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic designgoutamkrsahoo
 
Data representation
Data representationData representation
Data representationChew Hoong
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptxsulekhasaxena2
 
Data representation and Arithmetic Algorithms
Data representation and Arithmetic AlgorithmsData representation and Arithmetic Algorithms
Data representation and Arithmetic AlgorithmsMumthas Shaikh
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptskatiarrahaman
 
Akash Saha CSE 33 ADEpptx.pptx
Akash Saha CSE 33 ADEpptx.pptxAkash Saha CSE 33 ADEpptx.pptx
Akash Saha CSE 33 ADEpptx.pptxAkashSaha816377
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1Deepak John
 
B sc3 unit 2 number system
B sc3  unit 2 number systemB sc3  unit 2 number system
B sc3 unit 2 number systemMahiboobAliMulla
 

Similar to Dld lecture module 02 (20)

Lecture_5-2.ppt
Lecture_5-2.pptLecture_5-2.ppt
Lecture_5-2.ppt
 
Digital logic and design 02
Digital logic and design 02Digital logic and design 02
Digital logic and design 02
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbers
 
Number System 123.ppt is for binary number system
Number System 123.ppt is for binary number systemNumber System 123.ppt is for binary number system
Number System 123.ppt is for binary number system
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
 
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
 
Application of bases
Application of basesApplication of bases
Application of bases
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
 
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
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic design
 
Data representation
Data representationData representation
Data representation
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 
Data representation and Arithmetic Algorithms
Data representation and Arithmetic AlgorithmsData representation and Arithmetic Algorithms
Data representation and Arithmetic Algorithms
 
Number system
Number systemNumber system
Number system
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Akash Saha CSE 33 ADEpptx.pptx
Akash Saha CSE 33 ADEpptx.pptxAkash Saha CSE 33 ADEpptx.pptx
Akash Saha CSE 33 ADEpptx.pptx
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
 
B sc3 unit 2 number system
B sc3  unit 2 number systemB sc3  unit 2 number system
B sc3 unit 2 number system
 

More from Bilal Maqbool ツ

Programming assignment 02 (bilal maqbool 10) 2011
Programming assignment 02    (bilal maqbool 10) 2011Programming assignment 02    (bilal maqbool 10) 2011
Programming assignment 02 (bilal maqbool 10) 2011Bilal Maqbool ツ
 
Programming assignment 30 12-11
Programming assignment 30 12-11Programming assignment 30 12-11
Programming assignment 30 12-11Bilal Maqbool ツ
 
Presentation internet programming report
Presentation internet programming reportPresentation internet programming report
Presentation internet programming reportBilal Maqbool ツ
 
How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...Bilal Maqbool ツ
 
Advantages and disadvantages of LCD
Advantages and disadvantages of LCDAdvantages and disadvantages of LCD
Advantages and disadvantages of LCDBilal Maqbool ツ
 
Computing assignment 02 ms access (bilal maqbool 10) se-i
Computing assignment 02   ms access (bilal maqbool 10)          se-iComputing assignment 02   ms access (bilal maqbool 10)          se-i
Computing assignment 02 ms access (bilal maqbool 10) se-iBilal Maqbool ツ
 
Bilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computingBilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computingBilal Maqbool ツ
 

More from Bilal Maqbool ツ (19)

Lecture 3 report writtng
Lecture 3 report writtngLecture 3 report writtng
Lecture 3 report writtng
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1 report writing
Lecture 1 report writingLecture 1 report writing
Lecture 1 report writing
 
Bill gates
Bill gatesBill gates
Bill gates
 
Programming assignment 02 (bilal maqbool 10) 2011
Programming assignment 02    (bilal maqbool 10) 2011Programming assignment 02    (bilal maqbool 10) 2011
Programming assignment 02 (bilal maqbool 10) 2011
 
Programming assignment 30 12-11
Programming assignment 30 12-11Programming assignment 30 12-11
Programming assignment 30 12-11
 
Internet presentation
Internet presentationInternet presentation
Internet presentation
 
Presentation internet programming report
Presentation internet programming reportPresentation internet programming report
Presentation internet programming report
 
Magnetic storage devices
Magnetic storage devicesMagnetic storage devices
Magnetic storage devices
 
How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...
 
Math assignment Program
Math assignment ProgramMath assignment Program
Math assignment Program
 
Final of sentences PPT
Final of sentences PPTFinal of sentences PPT
Final of sentences PPT
 
Advantages and disadvantages of LCD
Advantages and disadvantages of LCDAdvantages and disadvantages of LCD
Advantages and disadvantages of LCD
 
A history of windows
A history of windowsA history of windows
A history of windows
 
Lcd
LcdLcd
Lcd
 
Bluetooth 27 01-12 PPT
Bluetooth 27 01-12 PPTBluetooth 27 01-12 PPT
Bluetooth 27 01-12 PPT
 
Bluetooth PPT Report
Bluetooth PPT ReportBluetooth PPT Report
Bluetooth PPT Report
 
Computing assignment 02 ms access (bilal maqbool 10) se-i
Computing assignment 02   ms access (bilal maqbool 10)          se-iComputing assignment 02   ms access (bilal maqbool 10)          se-i
Computing assignment 02 ms access (bilal maqbool 10) se-i
 
Bilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computingBilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computing
 

Recently uploaded

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Dld lecture module 02

  • 1. 3/28/2012 1 Digital Logic & Design Dr. Sajjad Ahmed Nadeem Department of Computer Science & IT University of Azad Jammu & Kashmir Muzaffarabad Module 02_01 Complements. The (r-1)’s Complement. The r’s Complement. Subtraction with Complements.
  • 2. 3/28/2012 2 Complements (1) Used in digital computers for ◦ simplifying the subtraction operation ◦ logical manipulations. There are two types of complements for each base-r system: 1. The (r – 1)’s Complement (Diminished radix complement). 2. The r’s Complement (Radix complement). For Decimal numbers we have 9’s and 10’s complement For Binary numbers we have 1’s and 2’s complement Complements (2) Complements of numbers with fractions 1. Remove the radix point 2. Obtain the complement 3. Return the radix point to its position
  • 3. 3/28/2012 3 The (r – 1)’s Complement (1) Let X be a positive number in base r with n digits, the (r – 1)’s complement of X is defined as (rⁿ - 1) – X For r=10, it is called 9’s complement and is given by (10ⁿ - 1) – X For r=2, it is called 1’s complement and is given by (2ⁿ - 1) – X The (r – 1)’s Complement (2) The 9’s complement of (52520)10 is {(105 – 1) – 52520} = 99999 – 52520 = 47479. The 9’s complement of (0.3267)10 is {(104 – 1) – 3267} = 9999 – 3267 = 6732. (Answer is 0.6732.) The 9’s complement of (25.639)10 is (105– 1– 25639) = 99999 – 25639 = 74360. (Answer is 74.360.)
  • 4. 3/28/2012 4 The (r – 1)’s Complement (3) The 1’s complement of (101100)2 is (26 – 1) 10 – (101100)2 = (111111 – 101100)2 = 010011. The 1’s complement of (0.0110)2 is (24 – 1)10 – (0110)2 = (1111 – 0110)2 = 1001. (Answer is 0.1001) The 1’s complement of (100.0110)2 is (27 – 1)10 – (1000110)2 = (1111111 – 1000110)2 = 0111001. (Answer is 011.1001) The (r – 1)’s Complement (4) The 9’s complement of a decimal number is formed simply by subtracting every digit from 9. The 1’s complement of a binary number is simpler to form: the 1’s are changed to 0’s and 0’s to 1’s.
  • 5. 3/28/2012 5 The r’s Complement (1) Let X be a positive number in base r with n digits, the r’s complement of X is defined as rⁿ – X for X ≠ 0 0 for X = 0 For r=10, it is called 10’s complement and is given by 10ⁿ – X = (10ⁿ – 1) – X + 1 For r=2, it is called 2’s complement and is given by 2ⁿ – X = (2ⁿ – 1) – X + 1 The r’s Complement (1) The 10’s complement of (52520)10 is (105 – 1) – 52520 + 1 = 47480. (The number of digits in the number is n=5.) The 10’s complement of (0.3267)10 is (104 – 1) – 3267 + 1 = 6733 (Answer is 0.6733) The 10’s complement of (25.639)10 is (105 – 1) – 25639 + 1= 74361 (Answer is 74.361)
  • 6. 3/28/2012 6 The r’s Complement (2) The 2’s Complement of (101100)2 is {(26 – 1)10 – (101100)2 }+ 1 = (111111 – 101100)+1 = 010100. The 2’s Complement of (0.0110)2 is {(24 – 1)10 – (0110)2 }+ 1 = 1010. (Answer is 0.1010) The r’s Complement (3) 10’s complement can be formed by ◦ leaving all least significant zeros unchanged and ◦ then subtracting the first non-zero least significant digit from 10, and ◦ then subtracting all other higher significant digits from 9. The 2’s Complement can be formed by ◦ leaving all least significant zeros and first non zero digit unchanged, and ◦ then replacing 1’s by 0’s and 0’s by 1’s in all other higher significant digits.
  • 7. 3/28/2012 7 Complement of Complement The complement of complement restores the number to its original value. The r’s complement of N is rⁿ - N. Therefore, the complement of (rⁿ - N) is rⁿ - (rⁿ - N) = N Subtraction with r’s compliment (1) The subtraction of two positive numbers (M – N), both of base r, may be done as follows. 1. Add the minuend M to the r’s complement of subtrahend N. M – N =M+ r’s complement (N) 2. Inspect the result obtained in step 1 for an end carry: (a) If an end carry occurs discard it. (b) If an end carry does not occur, take the r’s complement of the number obtained in step 1, and place a negative sign in front.
  • 8. 3/28/2012 8 Subtraction with r’s compliment (2) Using 10’s complement,subtract 72532 – 3250. M = 72532 , N = 03250. 10’s complement of subtrahend N = 96750. Step 1: 72532 + 96750 End Carry 1 69282 Step 2, discard carry. Answer = 69282. Subtraction with r’s compliment (3) Subtract: (3250 – 72532)10 M = 03250,N = 72532. 10’s complement of N = 27468. Step 1: 03250 + 27468 30718 (No End Carry) Step 2:Answer = - (10’s complement of 30718) Answer = - 69282
  • 9. 3/28/2012 9 Subtraction with r’s compliment (4) Using 2’s complement, subtract 1010100 – 1000100. M = 1010100,N = 1000100. 2’s complement of N = 0111100 Step 1: 1010100 + 0111100 End Carry 1 0010000 Step 2: Discard Carry. Answer = 0010000 Subtraction with r’s compliment (5) Using 2’s complement, subtract 1000100 – 1010100. M = 1000100,N = 1010100. 2’s complement of N = 0101100 Step 1: 1000100 + 0101100 No Carry 1110000 Step 2:Answer = - (2’s complement of 1110000) Answer = - 0010000
  • 10. 3/28/2012 10 Subtraction with (r – 1)’s compliment (1) The procedure for subtraction with the (r – 1)’s complement is exactly the same as the one used with r’s compliment except for one variation, called “end-round carry”. The subtraction of two positive numbers (M – N), both of base r, may be done as follows. 1. Add the minuend M to the (r – 1)’s complement of the subtrahend N. M – N =M+ (r – 1)’s complement (N) 2. Inspect the result obtained in step 1 for an End carry. (a) If an end carry occurs, add 1 to the least significant digit ( end-around carry). (b) If an end carry does not occur, take the (r – 1)’s complement of the number obtained in step 1 and place a negative sign in front. Using 9’s complement, subtract 72532 – 3250. M = 72532 , N = 03250. 9’s complement of subtrahend N = 96749. Step 1: 72532 + 96749 End-around Carry 1 69281 Step 2,add end around carry. + 1 Answer = 69282 Subtraction with (r – 1)’s compliment (2)
  • 11. 3/28/2012 11 Subtract: (3250 – 72532)10 M = 03250,N = 72532. 9’s complement of N = 27467. Step 1: 03250 + 27467 30717 (No End Carry) Step 2:Answer = - (9’s complement of 30717) Answer = - 69282 Subtraction with (r – 1)’s compliment (3) Using 1’s complement, subtract 1010100 – 1000100. M = 1010100,N = 1000100. 1’s complement of N = 0111011 Step 1: 1010100 + 0111011 End Carry 1 0001111 Step 2 + 1 Answer = 0010000 Subtraction with (r – 1)’s compliment (4)
  • 12. 3/28/2012 12 Using 1’s complement, subtract 1000100 – 1010100. M = 1000100,N = 1010100. 1’s complement of N = 0101011 Step 1: 1000100 + 0101011 No Carry 1101111 Step 2:Answer = - (1’s complement of 1101111) Answer = - 10000 Subtraction with (r – 1)’s compliment (5) Signed Binary Numbers (1) We have one way to represent a positive number (say +9) Three ways to represent a negative numbers (say -9) Sign Bit ◦ Signed-magnitude representation 1 0001001 ◦ Signed-1’s complement representation 1 1110110 ◦ Signed-2’s complement representation 1 1110111
  • 13. 3/28/2012 13 Signed Binary Numbers (2) Signed Binary Numbers-Addition Addition of two numbers in signed magnitude system follow the same rules of ordinary arithmatic. The addition of two signed binary numbers ◦ Use binary representation of the numbers and add them ◦ In case of negative number, add the 2’s complement of the negative number to the positive number alongwith sign bits ◦ Add the 2’s complement of the negative numbers ◦ A carry out of the sign bit position is discarded ◦ If the sum obtained is in negative it is automatically in 2’s complement form.
  • 14. 3/28/2012 14 Signed Binary Numbers-Subtraction Take the 2’s complement of the subtrahed (including the sign bit) Add the obtained 2’s complement to the minuend (including the sign bit). A carry out of sign bit is discarded Assignment r’s complement for octal & hexadecimal (r-1)’s complement for octal & hexadecimal Comparison between 1’s and 2’s Complement.