SlideShare a Scribd company logo
William Stallings
Computer Organization
and Architecture
Chapter 9
Computer Arithmetic
Key Points
 Two principle concerns for computer
arithmetic
• the way in which numbers are
represented
• the algorithms used for the basic
arithmetic operations
These two considerations apply both to integer
and floating point arithmetic
 part of the computer that actually
performs arithmetic and logical
operations on data.
 Handles integers
 May handle floating point (real)
numbers
Arithmetic & Logic Unit (ALU)
ALU Inputs and Outputs
Integer Representation
Only have 0 & 1 to represent everything
Positive numbers stored in binary
e.g. 41=00101001
No minus sign
No period
Sign-Magnitude
Two’s complement
Sign-Magnitude
Left most bit is sign bit
0 means positive
1 means negative
+18 = 00010010
 -18 = 10010010
Problems
Need to consider both sign and magnitude in
arithmetic
Two representations of zero (+0 and -0)
Two’s Complement
+3 = 00000011
+2 = 00000010
+1 = 00000001
+0 = 00000000
-1 = 11111111
-2 = 11111110
-3 = 11111101
Benefits of 2’s complement
 One representation of zero
 Arithmetic works easily (see later)
 Negating is fairly easy
3 = 00000011
Boolean complement gives 11111100
Add 1 to LSB 11111101
Geometric Depiction of Twos
Complement Integers
Negation Special Case 1
 0 = 00000000
Bitwise not 11111111
Add 1 to LSB +1
Result 1 00000000
Overflow is ignored, so:
- 0 = 0 
Negation Special Case 2
-128 = 10000000
bitwise not 01111111
Add 1 to LSB +1
Result 10000000
So:
-(-128) = -128 X
Monitor MSB (sign bit)
It should change during negation
Range of Numbers
8 bit 2’s complement
+127 = 01111111 = 2 -1
 -128 = 10000000 = -2
16 bit 2’s complement
+32767 = 011111111 11111111 = 2 - 1
 -32768 = 100000000 00000000 = - 2
Conversion Between Lengths
Positive number pack with leading zeros
+18 = 00010010(sign magnitude, 8bits)
+18 = 00000000 00010010(sign magnitude,16bits)
Negative numbers pack with leading ones
-18 = 10010010(sign magnitude, 8bits)
-18 = 10000000 10010010(sign magnitude,16bits)
i.e. pack with MSB (sign bit)
Addition and Subtraction
Normal binary addition
Monitor sign bit for overflow
Take two’s complement of subtrahend and
add to minuend
i.e. a - b = a + (-b)
So we only need addition and complement
circuits
Hardware for Addition and
Subtraction
Multiplication
Complex
Work out partial product for each digit
Take care with place value (column)
Add partial products
Multiplication Example
1011 Multiplicand (11 dec)
x 1101 Multiplier (13 dec)
1011 Partial products
0000
1011
1011
10001111 Product (143 dec)
 Note: need double length result
if multiplier bit is 1 copy
otherwise zero
Flowchart for Unsigned Binary
Multiplication
Execution of Example
Unsigned Binary Multiplication
Multiplying Negative Numbers
Solution 1
 Convert to positive if required
Multiply as above
If signs were different, negate answer
Solution 2
Booth’s algorithm
Division
More complex than multiplication
Negative numbers are really bad!
Based on long division
ASSIGNMENT
Multiplying Negative
Numbers
(Booth’s algorithm)

More Related Content

Similar to Computer Arithmetic_Computer_Architecture.ppt (20)

PDF
2.1COMPUTER ORG_ Computer Arithmetic.pdf
RajeshSingamaneni1
 
PPT
09 arithmetic
dilip kumar
 
PPT
index of all of the financial accounts in a company's general ledger. In shor...
mayurjagdale4
 
PPTX
Computer Organization - Arithmetic & Logic Unit.pptx
AnanyaMalik7
 
PPTX
COA(Unit_3.pptx)
Thapar Institute
 
PPT
09 arithmetic 2
Sher Shah Merkhel
 
PPT
09 arithmetic
Sher Shah Merkhel
 
PPT
09 arithmetic
argiaggi
 
PPT
CA.ppt
etrcet1
 
PPT
ARITHMETIC LOGIC UNIT.ppt
RAJESH S
 
PDF
Arithmatic Ch 10 (4).pdf
SahilSarda2
 
PDF
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
IIUM
 
PDF
Computer arithmetic
Usiju Gadzama
 
PPT
computer arithmatic
mahesh kumar prajapat
 
PPT
Counit2
Himanshu Dua
 
PPTX
Lec20
Zain Ul Abedeen
 
PPTX
Computer Architecture
Ravi Kumar
 
PPTX
Computer Architecture
Ravi Kumar
 
PPTX
1.COMPUTER ARITHMETIC which is related to coa.pptx
n200886
 
PPTX
Computer Arithmatic Operation Computer Arithmetic Presentation.pptx
TarunDatta3
 
2.1COMPUTER ORG_ Computer Arithmetic.pdf
RajeshSingamaneni1
 
09 arithmetic
dilip kumar
 
index of all of the financial accounts in a company's general ledger. In shor...
mayurjagdale4
 
Computer Organization - Arithmetic & Logic Unit.pptx
AnanyaMalik7
 
COA(Unit_3.pptx)
Thapar Institute
 
09 arithmetic 2
Sher Shah Merkhel
 
09 arithmetic
Sher Shah Merkhel
 
09 arithmetic
argiaggi
 
CA.ppt
etrcet1
 
ARITHMETIC LOGIC UNIT.ppt
RAJESH S
 
Arithmatic Ch 10 (4).pdf
SahilSarda2
 
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
IIUM
 
Computer arithmetic
Usiju Gadzama
 
computer arithmatic
mahesh kumar prajapat
 
Counit2
Himanshu Dua
 
Computer Architecture
Ravi Kumar
 
Computer Architecture
Ravi Kumar
 
1.COMPUTER ARITHMETIC which is related to coa.pptx
n200886
 
Computer Arithmatic Operation Computer Arithmetic Presentation.pptx
TarunDatta3
 

Recently uploaded (20)

PDF
Plant Control_EST_85520-01_en_AllChanges_20220127.pdf
DarshanaChathuranga4
 
PPTX
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
PDF
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
PPTX
Work at Height training for workers .pptx
cecos12
 
PDF
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
PDF
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
PDF
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
 
PDF
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PDF
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
PPTX
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
 
PDF
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PDF
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
PPT
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
Plant Control_EST_85520-01_en_AllChanges_20220127.pdf
DarshanaChathuranga4
 
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
Work at Height training for workers .pptx
cecos12
 
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
 
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
 
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
Ad

Computer Arithmetic_Computer_Architecture.ppt