SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Basic of number system
Basic of number systemBasic of number system
Basic of number system
 
G. ripple counter
G. ripple counterG. ripple counter
G. ripple counter
 
Decimal number system
Decimal number systemDecimal number system
Decimal number system
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
 
BCD ADDER
BCD ADDER BCD ADDER
BCD ADDER
 
Adder ppt
Adder pptAdder ppt
Adder ppt
 
Structural modelling
Structural modellingStructural modelling
Structural modelling
 
Edge Trigged Flip Flops
Edge Trigged Flip FlopsEdge Trigged Flip Flops
Edge Trigged Flip Flops
 
Introduction to digital electornics
Introduction to digital electornicsIntroduction to digital electornics
Introduction to digital electornics
 
Flip flop’s state tables & diagrams
Flip flop’s state tables & diagramsFlip flop’s state tables & diagrams
Flip flop’s state tables & diagrams
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complements
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Presentation On Flip-Flop
Presentation On Flip-FlopPresentation On Flip-Flop
Presentation On Flip-Flop
 
Data & Databases
Data & Databases Data & Databases
Data & Databases
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Basics Counters
Basics Counters Basics Counters
Basics Counters
 
Binary true ppt
Binary true pptBinary true ppt
Binary true ppt
 
Digital Electronics Notes
Digital Electronics Notes Digital Electronics Notes
Digital Electronics Notes
 
Constants, Variables, and Data Types
Constants, Variables, and Data TypesConstants, Variables, and Data Types
Constants, Variables, and Data Types
 

Destacado (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 a 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
 
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 numbersMohammad Bashartullah
 
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
 

Similar a 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
 
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
 
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
 
Number System
Number SystemNumber System
Number System
 
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
 

Más de 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 ツ
 

Más de 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
 

Último

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 

Último (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

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.