SlideShare a Scribd company logo
Arithmetic & Logic Unit
• Does the calculations
• Everything else in the computer is there
to service this unit
• Handles integers
• May handle floating point (real) numbers
• May be separate FPU (maths co-
processor)
• May be on chip separate FPU (486DX +)
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 compliment
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 Complment
• +3 = 00000011
• +2 = 00000010
• +1 = 00000001
• +0 = 00000000
• -1 = 11111111
• -2 = 11111110
• -3 = 11111101
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
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 2s compliment
—+127 = 01111111 = 27
-1
— -128 = 10000000 = -27
• 16 bit 2s compliment
—+32767 = 011111111 11111111 = 215
- 1
— -32768 = 100000000 00000000 = -215
Conversion Between Lengths
• Positive number pack with leading zeros
• +18 = 00010010
• +18 = 00000000 00010010
• Negative numbers pack with leading ones
• -18 = 10010010
• -18 = 11111111 10010010
• i.e. pack with MSB (sign bit)
Addition and Subtraction
• Normal binary addition
• Monitor sign bit for overflow
• Take twos compliment of substahend 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 Note: if multiplier bit is 1 copy
• 1011 multiplicand (place value)
• 1011 otherwise zero
• 10001111 Product (143 dec)
• Note: need double length result
Unsigned Binary Multiplication
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
Division
• More complex than multiplication
• Negative numbers are really bad!
• Based on long division
00111
1
Division of Unsigned Binary Integers
1011
00001101
10010011
1011
00111
0 101
1
101
1100
Quotien
t
Dividen
d
Remainde
r
Partial
Remainder
s
Diviso
r
Flowchart for Unsigned Binary Division
Real Numbers
• Numbers with fractions
• Could be done in pure binary
—1001.1010 = 23
+ 20
+2-1
+ 2-3
=9.625
• Where is the binary point?
• Fixed?
—Very limited
• Moving?
—How do you show where it is?
Floating Point
• +/- .significand x 2exponent
• Misnomer
• Point is actually fixed between sign bit and body
of mantissa
• Exponent indicates place value (point position)
Misnomer:เรียกชื่อ
Floating Point Examples
Signs for Floating Point
• Mantissa is stored in 2s compliment
• Exponent is in excess or biased notation
—e.g. Excess (bias) 128 means
—8 bit exponent field
—Pure value range 0-255
—Subtract 128 to get correct value
—Range -128 to +127
Normalization
• FP numbers are usually normalized
• i.e. exponent is adjusted so that leading
bit (MSB) of mantissa is 1
• Since it is always 1 there is no need to
store it
• (c.f. Scientific notation where numbers are
normalized to give a single digit before
the decimal point
• e.g. 3.123 x 103
)
FP Ranges
• For a 32 bit number
—8 bit exponent
—+/- 2256
≈ 1.5 x 1077
• Accuracy
—The effect of changing lsb of mantissa
—23 bit mantissa 2-23
≈ 1.2 x 10-7
—About 6 decimal places
Expressible Numbers
Density of Floating Point Numbers
IEEE 754
• Standard for floating point storage
• 32 and 64 bit standards
• 8 and 11 bit exponent respectively
• Extended formats (both mantissa and
exponent) for intermediate results
IEEE 754 Formats
FP Arithmetic +/-
• Check for zeros
• Align significands (adjusting exponents)
• Add or subtract significands
• Normalize result
FP Addition & Subtraction Flowchart
FP Arithmetic x/÷
• Check for zero
• Add/subtract exponents
• Multiply/divide significands (watch sign)
• Normalize
• Round
• All intermediate results should be in
double length storage
Floating Point Multiplication
Floating Point Division
Required Reading
• Stallings Chapter 9
• IEEE 754 on IEEE Web site

More Related Content

PPT
arithmetic
SaifullahSiddiqui7
 
PPT
09 arithmetic
dilip kumar
 
PPT
09 arithmetic 2
Sher Shah Merkhel
 
PPT
09 arithmetic
Sher Shah Merkhel
 
PPT
09 arithmetic
argiaggi
 
PPT
09 Arithmetic
Jeanie Delos Arcos
 
PPTX
Chapter 6
Er. Nawaraj Bhandari
 
PDF
Organisasi dan Arsitektur Komputer MO-08
EriekOrlando
 
arithmetic
SaifullahSiddiqui7
 
09 arithmetic
dilip kumar
 
09 arithmetic 2
Sher Shah Merkhel
 
09 arithmetic
Sher Shah Merkhel
 
09 arithmetic
argiaggi
 
09 Arithmetic
Jeanie Delos Arcos
 
Organisasi dan Arsitektur Komputer MO-08
EriekOrlando
 

Similar to Computer Organization - Arithmetic & Logic Unit.pptx (20)

PPT
Counit2
Himanshu Dua
 
PPTX
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
Abhishek Rajpoot
 
PPTX
A floating-point adder (IEEE 754 floating-point.pptx
NiveditaAcharyya2035
 
PPTX
Data processing and processor organisation
AnsariArfat
 
PDF
Floating_point_representation.pdf
RameshK531901
 
PPT
CSe_Cumilla Bangladeshrr_Country CSE CSE213_5.ppt
roy5th6th
 
PPTX
Floating point arithmetic operations (1)
cs19club
 
PPT
Computer Arithmetic_Computer_Architecture.ppt
fairuzahmed13579
 
PPT
Arithmetic unit.ppt
MSMinuSanjudharan
 
PPTX
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Shwetamaurya36
 
PDF
MCS222-DDCA-Lec.7-111111111111111111.pdf
RashaOrban2
 
PPTX
module 1_class_numbers.pptx
ssuser2efca7
 
PPTX
CA UNIT II.pptx
ssuser9dbd7e
 
PDF
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
IIUM
 
PDF
Notes unit 2
KamarajA5
 
PPTX
Computer Architecture and Organization- arithmetic
C.Helen Sulochana
 
PPT
index of all of the financial accounts in a company's general ledger. In shor...
mayurjagdale4
 
PDF
Binaty Arithmetic and Binary coding schemes
Dr. Anita Goel
 
PPTX
Data Reprersentation
Kamal Acharya
 
PPTX
datareprersentation 1.pptx
Ramakrishna Reddy Bijjam
 
Counit2
Himanshu Dua
 
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
Abhishek Rajpoot
 
A floating-point adder (IEEE 754 floating-point.pptx
NiveditaAcharyya2035
 
Data processing and processor organisation
AnsariArfat
 
Floating_point_representation.pdf
RameshK531901
 
CSe_Cumilla Bangladeshrr_Country CSE CSE213_5.ppt
roy5th6th
 
Floating point arithmetic operations (1)
cs19club
 
Computer Arithmetic_Computer_Architecture.ppt
fairuzahmed13579
 
Arithmetic unit.ppt
MSMinuSanjudharan
 
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Shwetamaurya36
 
MCS222-DDCA-Lec.7-111111111111111111.pdf
RashaOrban2
 
module 1_class_numbers.pptx
ssuser2efca7
 
CA UNIT II.pptx
ssuser9dbd7e
 
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
IIUM
 
Notes unit 2
KamarajA5
 
Computer Architecture and Organization- arithmetic
C.Helen Sulochana
 
index of all of the financial accounts in a company's general ledger. In shor...
mayurjagdale4
 
Binaty Arithmetic and Binary coding schemes
Dr. Anita Goel
 
Data Reprersentation
Kamal Acharya
 
datareprersentation 1.pptx
Ramakrishna Reddy Bijjam
 
Ad

Recently uploaded (20)

PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PDF
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PPT
Understanding the Key Components and Parts of a Drone System.ppt
Siva Reddy
 
PPT
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Inventory management chapter in automation and robotics.
atisht0104
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
Understanding the Key Components and Parts of a Drone System.ppt
Siva Reddy
 
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Ad

Computer Organization - Arithmetic & Logic Unit.pptx

  • 1. Arithmetic & Logic Unit • Does the calculations • Everything else in the computer is there to service this unit • Handles integers • May handle floating point (real) numbers • May be separate FPU (maths co- processor) • May be on chip separate FPU (486DX +)
  • 2. ALU Inputs and Outputs
  • 3. 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 compliment
  • 4. 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)
  • 5. Two’s Complment • +3 = 00000011 • +2 = 00000010 • +1 = 00000001 • +0 = 00000000 • -1 = 11111111 • -2 = 11111110 • -3 = 11111101
  • 6. 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
  • 7. Geometric Depiction of Twos Complement Integers
  • 8. Negation Special Case 1 • 0 = 00000000 • Bitwise not 11111111 • Add 1 to LSB +1 • Result 1 00000000 • Overflow is ignored, so: • - 0 = 0 √
  • 9. 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
  • 10. Range of Numbers • 8 bit 2s compliment —+127 = 01111111 = 27 -1 — -128 = 10000000 = -27 • 16 bit 2s compliment —+32767 = 011111111 11111111 = 215 - 1 — -32768 = 100000000 00000000 = -215
  • 11. Conversion Between Lengths • Positive number pack with leading zeros • +18 = 00010010 • +18 = 00000000 00010010 • Negative numbers pack with leading ones • -18 = 10010010 • -18 = 11111111 10010010 • i.e. pack with MSB (sign bit)
  • 12. Addition and Subtraction • Normal binary addition • Monitor sign bit for overflow • Take twos compliment of substahend and add to minuend —i.e. a - b = a + (-b) • So we only need addition and complement circuits
  • 13. Hardware for Addition and Subtraction
  • 14. Multiplication • Complex • Work out partial product for each digit • Take care with place value (column) • Add partial products
  • 15. Multiplication Example • 1011 Multiplicand (11 dec) • x 1101 Multiplier (13 dec) • 1011 Partial products • 0000 Note: if multiplier bit is 1 copy • 1011 multiplicand (place value) • 1011 otherwise zero • 10001111 Product (143 dec) • Note: need double length result
  • 18. Flowchart for Unsigned Binary Multiplication
  • 19. 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
  • 21. Example of Booth’s Algorithm
  • 22. Division • More complex than multiplication • Negative numbers are really bad! • Based on long division
  • 23. 00111 1 Division of Unsigned Binary Integers 1011 00001101 10010011 1011 00111 0 101 1 101 1100 Quotien t Dividen d Remainde r Partial Remainder s Diviso r
  • 24. Flowchart for Unsigned Binary Division
  • 25. Real Numbers • Numbers with fractions • Could be done in pure binary —1001.1010 = 23 + 20 +2-1 + 2-3 =9.625 • Where is the binary point? • Fixed? —Very limited • Moving? —How do you show where it is?
  • 26. Floating Point • +/- .significand x 2exponent • Misnomer • Point is actually fixed between sign bit and body of mantissa • Exponent indicates place value (point position) Misnomer:เรียกชื่อ
  • 28. Signs for Floating Point • Mantissa is stored in 2s compliment • Exponent is in excess or biased notation —e.g. Excess (bias) 128 means —8 bit exponent field —Pure value range 0-255 —Subtract 128 to get correct value —Range -128 to +127
  • 29. Normalization • FP numbers are usually normalized • i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1 • Since it is always 1 there is no need to store it • (c.f. Scientific notation where numbers are normalized to give a single digit before the decimal point • e.g. 3.123 x 103 )
  • 30. FP Ranges • For a 32 bit number —8 bit exponent —+/- 2256 ≈ 1.5 x 1077 • Accuracy —The effect of changing lsb of mantissa —23 bit mantissa 2-23 ≈ 1.2 x 10-7 —About 6 decimal places
  • 32. Density of Floating Point Numbers
  • 33. IEEE 754 • Standard for floating point storage • 32 and 64 bit standards • 8 and 11 bit exponent respectively • Extended formats (both mantissa and exponent) for intermediate results
  • 35. FP Arithmetic +/- • Check for zeros • Align significands (adjusting exponents) • Add or subtract significands • Normalize result
  • 36. FP Addition & Subtraction Flowchart
  • 37. FP Arithmetic x/÷ • Check for zero • Add/subtract exponents • Multiply/divide significands (watch sign) • Normalize • Round • All intermediate results should be in double length storage
  • 40. Required Reading • Stallings Chapter 9 • IEEE 754 on IEEE Web site