SlideShare a Scribd company logo
Computer
Arithmetic
KAMRAN RIASAT … 18
MUHAMMAD HASNAIN … 29
MUHAMMAD SAIF ULLAH … 30
USAMA ALI … 38
Chapter 09
Arithmetic & Logic Unit (ALU)
 Part of the computer that actually performs
arithmetic and logical operations on data
 All of the other elements of the computer system
are there mainly to bring data into the ALU for it to
process and then to take the results back out
 Based on the use of simple digital logic devices
that can store binary digits and perform simple
Boolean logic operations
ALU
Inputs
and
Outputs
Integer Representation
 In the binary number system arbitrary numbers can be
represented with:
▪ The digits zero and one
▪ The minus sign (for negative numbers)
▪ The period, or radix point (for numbers with a fractional component)
 For purposes of computer storage and processing we do not have
the benefit of special symbols for the minus sign and radix point
 Only binary digits (0,1) may be used to represent numbers
Sign-Magnitude Representation
 Left most bit is sign bit
 0 means positive
 1 means negative
 Drawbacks:
▪ Need to consider both sign and magnitude in arithmetic
▪ Two representations of zero (+0 and -0)
 Rarely used in implementing the integer portion of the ALU
Twos Complement Representation
 Uses the most significant bit as a sign bit
 Differs from sign-magnitude representation in the way that the other bits
are interpreted
Table 9.2
Alternative Representations for 4-Bit Integers
Benefits
 One representation of zero
 Arithmetic works easily (see later)
 Negating is fairly easy
▪ 3 = 00000011
▪ Boolean complement gives 11111100
▪ Add 1 to LSB 11111101
Range Extension
 Range of numbers that can be expressed is extended by
increasing the bit length
 In sign-magnitude notation this is accomplished by moving the
sign bit to the new leftmost position and fill in with zeros
 This procedure will not work for twos complement negative
integers
▪Rule is to move the sign bit to the new leftmost position and fill in with
copies of the sign bit
▪For positive numbers, fill in with zeros, and for negative numbers, fill in
with ones
▪This is called sign extension
Fixed-Point Representation
The radix point (binary point)
is fixed and assumed to be to
the right of the rightmost digit
Programmer can use the
same representation for
binary fractions by scaling the
numbers so that the binary
point is implicitly positioned
at some other location
Integer Arithmetic
Negation(Twos Complement)
 Twos complement operation
▪ Take the Boolean complement of each bit of the integer (including the sign bit)
▪ Treating the result as an unsigned binary integer, add 1
 The negative of the negative of that number is itself:
+18 = 00010010 (twos complement)
bitwise complement = 11101101
+ 1
11101110 = -18
-18 = 11101110 (twos complement)
bitwise complement = 00010001
+ 1
00010010 = +18
Addition
OVERFLOW RULE:
 If two numbers are added, and they are both positive or
both negative, then overflow occurs if and only if the result
has the opposite sign.
Negation Special Case 1
0 = 00000000 (twos complement)
Bitwise complement = 11111111
Add 1 to LSB + 1
Result 100000000
Overflow is ignored, so:
- 0 = 0
Negation Special Case 2
-128 = 10000000 (twos complement)
Bitwise complement = 01111111
Add 1 to LSB + 1
Result 10000000
So:
-(-128) = -128 X
Monitor MSB (sign bit)
It should change during negation
SUBTRACTION RULE:
Rules:
1. To subtract one number (subtrahend) from another
(minuend)
2. Take the twos complement (negation) of the subtrahend
3. And add it to the minuend.
Subtraction
Hardware for Addition and
Subtraction
Figure 9.6 Block diagram of Hardware for Addition and Subtraction
MULTIPLICATION
Multiplication
 Complex
 Work out partial product for each digit
 Take care with place value (column)
 Add partial product
Multiplication Example
1011 Multiplicand (11 dec)
x 1101 Multiplier (13 dec)
1011 Partial products
0000x Note: if multiplier bit is 1 copy
1011xx Multiplicand (place value)
1011xxx Otherwise zero
10001111 Product (143 dec)
Note: need double length result`
Execution of Example
Flowchart for Unsigned Binary
Multiplication
Multiplying Negative Numbers
This does not work!
Solution 1
▪ Convert to positive if required
▪ Multiply as above
▪ If signs were different, negate answer
Solution 2
▪ Booth’s algorithm
Booth’s
Algorithm
Example of Booth’s Algorithm
Examples Using Booth’s Algorithm
Division
Flowchart for
Unsigned
Binary
Division
Example of Restoring Twos Complement
Division
Thank You

More Related Content

What's hot

Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
Keyur Vadodariya
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
Balakrishna Chowdary
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Chapter 6
Chapter 6Chapter 6
Lecture2 binary multiplication
Lecture2 binary multiplicationLecture2 binary multiplication
Lecture2 binary multiplication景文 饶
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmeticIIUI
 
arithmetic
arithmeticarithmetic
arithmetic
SaifullahSiddiqui7
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
Gaurav Subham
 
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
 
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
 
Multiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchartMultiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchart
Tanjarul Islam Mishu
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
Anil Pokhrel
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
Kamal Acharya
 
Booths algorithm for Multiplication
Booths algorithm for MultiplicationBooths algorithm for Multiplication
Booths algorithm for Multiplication
Vikas Yadav
 
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
Arti Parab Academics
 
Computer architecture
Computer architectureComputer architecture
Computer architectureSanjeev Patel
 

What's hot (19)

09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
05 multiply divide
05 multiply divide05 multiply divide
05 multiply divide
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Lecture2 binary multiplication
Lecture2 binary multiplicationLecture2 binary multiplication
Lecture2 binary multiplication
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
arithmetic
arithmeticarithmetic
arithmetic
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
 
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
 
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
 
Multiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchartMultiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchart
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
 
Booths algorithm for Multiplication
Booths algorithm for MultiplicationBooths algorithm for Multiplication
Booths algorithm for Multiplication
 
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 

Similar to Integer represention

index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...
mayurjagdale4
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...
mayurjagdale4
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
Shankar Gangaju
 
Arithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsArithmetic Process in Computer Systems
Arithmetic Process in Computer Systems
S N M P Simamora
 
computer arithmatic
computer arithmaticcomputer arithmatic
computer arithmatic
mahesh kumar prajapat
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
RavikumarR77
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdf
GafryMahmoud
 
Alu1
Alu1Alu1
Data Representation.pptx
Data Representation.pptxData Representation.pptx
Data Representation.pptx
nivedita murugan
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
TamiratDejene1
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
skatiarrahaman
 
Computer arithmetic operations.pptx
Computer arithmetic operations.pptxComputer arithmetic operations.pptx
Computer arithmetic operations.pptx
ssusera6fdd5
 
Unit ii ca--arithmetic
Unit ii ca--arithmeticUnit ii ca--arithmetic
Unit ii ca--arithmetic
Praba haran
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
Arti Parab Academics
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
arunachalamr16
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2
Dr.MAYA NAYAK
 
unit-2_DL.pdf
unit-2_DL.pdfunit-2_DL.pdf
unit-2_DL.pdf
ashoksahu64
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
MtikuTadesse
 

Similar to Integer represention (20)

index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
 
Arithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsArithmetic Process in Computer Systems
Arithmetic Process in Computer Systems
 
computer arithmatic
computer arithmaticcomputer arithmatic
computer arithmatic
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdf
 
Alu1
Alu1Alu1
Alu1
 
Data Representation.pptx
Data Representation.pptxData Representation.pptx
Data Representation.pptx
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
Computer arithmetic operations.pptx
Computer arithmetic operations.pptxComputer arithmetic operations.pptx
Computer arithmetic operations.pptx
 
Unit ii ca--arithmetic
Unit ii ca--arithmeticUnit ii ca--arithmetic
Unit ii ca--arithmetic
 
2's complement
2's complement2's complement
2's complement
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2
 
unit-2_DL.pdf
unit-2_DL.pdfunit-2_DL.pdf
unit-2_DL.pdf
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
 

Recently uploaded

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 

Recently uploaded (20)

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 

Integer represention

  • 1. Computer Arithmetic KAMRAN RIASAT … 18 MUHAMMAD HASNAIN … 29 MUHAMMAD SAIF ULLAH … 30 USAMA ALI … 38 Chapter 09
  • 2. Arithmetic & Logic Unit (ALU)  Part of the computer that actually performs arithmetic and logical operations on data  All of the other elements of the computer system are there mainly to bring data into the ALU for it to process and then to take the results back out  Based on the use of simple digital logic devices that can store binary digits and perform simple Boolean logic operations
  • 4.
  • 5. Integer Representation  In the binary number system arbitrary numbers can be represented with: ▪ The digits zero and one ▪ The minus sign (for negative numbers) ▪ The period, or radix point (for numbers with a fractional component)  For purposes of computer storage and processing we do not have the benefit of special symbols for the minus sign and radix point  Only binary digits (0,1) may be used to represent numbers
  • 6. Sign-Magnitude Representation  Left most bit is sign bit  0 means positive  1 means negative  Drawbacks: ▪ Need to consider both sign and magnitude in arithmetic ▪ Two representations of zero (+0 and -0)  Rarely used in implementing the integer portion of the ALU
  • 7. Twos Complement Representation  Uses the most significant bit as a sign bit  Differs from sign-magnitude representation in the way that the other bits are interpreted
  • 9. Benefits  One representation of zero  Arithmetic works easily (see later)  Negating is fairly easy ▪ 3 = 00000011 ▪ Boolean complement gives 11111100 ▪ Add 1 to LSB 11111101
  • 10. Range Extension  Range of numbers that can be expressed is extended by increasing the bit length  In sign-magnitude notation this is accomplished by moving the sign bit to the new leftmost position and fill in with zeros  This procedure will not work for twos complement negative integers ▪Rule is to move the sign bit to the new leftmost position and fill in with copies of the sign bit ▪For positive numbers, fill in with zeros, and for negative numbers, fill in with ones ▪This is called sign extension
  • 11. Fixed-Point Representation The radix point (binary point) is fixed and assumed to be to the right of the rightmost digit Programmer can use the same representation for binary fractions by scaling the numbers so that the binary point is implicitly positioned at some other location
  • 13. Negation(Twos Complement)  Twos complement operation ▪ Take the Boolean complement of each bit of the integer (including the sign bit) ▪ Treating the result as an unsigned binary integer, add 1  The negative of the negative of that number is itself: +18 = 00010010 (twos complement) bitwise complement = 11101101 + 1 11101110 = -18 -18 = 11101110 (twos complement) bitwise complement = 00010001 + 1 00010010 = +18
  • 15. OVERFLOW RULE:  If two numbers are added, and they are both positive or both negative, then overflow occurs if and only if the result has the opposite sign.
  • 16. Negation Special Case 1 0 = 00000000 (twos complement) Bitwise complement = 11111111 Add 1 to LSB + 1 Result 100000000 Overflow is ignored, so: - 0 = 0
  • 17. Negation Special Case 2 -128 = 10000000 (twos complement) Bitwise complement = 01111111 Add 1 to LSB + 1 Result 10000000 So: -(-128) = -128 X Monitor MSB (sign bit) It should change during negation
  • 18. SUBTRACTION RULE: Rules: 1. To subtract one number (subtrahend) from another (minuend) 2. Take the twos complement (negation) of the subtrahend 3. And add it to the minuend.
  • 20. Hardware for Addition and Subtraction Figure 9.6 Block diagram of Hardware for Addition and Subtraction
  • 22. Multiplication  Complex  Work out partial product for each digit  Take care with place value (column)  Add partial product
  • 23. Multiplication Example 1011 Multiplicand (11 dec) x 1101 Multiplier (13 dec) 1011 Partial products 0000x Note: if multiplier bit is 1 copy 1011xx Multiplicand (place value) 1011xxx Otherwise zero 10001111 Product (143 dec) Note: need double length result`
  • 25. Flowchart for Unsigned Binary Multiplication
  • 26. Multiplying Negative Numbers This does not work! Solution 1 ▪ Convert to positive if required ▪ Multiply as above ▪ If signs were different, negate answer Solution 2 ▪ Booth’s algorithm
  • 28. Example of Booth’s Algorithm
  • 32. Example of Restoring Twos Complement Division