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
PPT
09 arithmetic
PPT
09 arithmetic 2
PPT
09 arithmetic
PPT
09 arithmetic
PPT
09 Arithmetic
PPTX
PDF
Organisasi dan Arsitektur Komputer MO-08
arithmetic
09 arithmetic
09 arithmetic 2
09 arithmetic
09 arithmetic
09 Arithmetic
Organisasi dan Arsitektur Komputer MO-08

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

PPT
Counit2
PPTX
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
PPTX
A floating-point adder (IEEE 754 floating-point.pptx
PPTX
Data processing and processor organisation
PDF
Floating_point_representation.pdf
PPT
CSe_Cumilla Bangladeshrr_Country CSE CSE213_5.ppt
PPTX
Floating point arithmetic operations (1)
PPT
Computer Arithmetic_Computer_Architecture.ppt
PPT
Arithmetic unit.ppt
PPTX
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
PDF
MCS222-DDCA-Lec.7-111111111111111111.pdf
PPTX
module 1_class_numbers.pptx
PPTX
CA UNIT II.pptx
PDF
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
PDF
Notes unit 2
PPTX
Computer Architecture and Organization- arithmetic
PPT
index of all of the financial accounts in a company's general ledger. In shor...
PDF
Binaty Arithmetic and Binary coding schemes
PPTX
Data Reprersentation
PPTX
datareprersentation 1.pptx
Counit2
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
A floating-point adder (IEEE 754 floating-point.pptx
Data processing and processor organisation
Floating_point_representation.pdf
CSe_Cumilla Bangladeshrr_Country CSE CSE213_5.ppt
Floating point arithmetic operations (1)
Computer Arithmetic_Computer_Architecture.ppt
Arithmetic unit.ppt
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
MCS222-DDCA-Lec.7-111111111111111111.pdf
module 1_class_numbers.pptx
CA UNIT II.pptx
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Notes unit 2
Computer Architecture and Organization- arithmetic
index of all of the financial accounts in a company's general ledger. In shor...
Binaty Arithmetic and Binary coding schemes
Data Reprersentation
datareprersentation 1.pptx
Ad

Recently uploaded (20)

PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PPTX
Feature types and data preprocessing steps
PDF
Design Guidelines and solutions for Plastics parts
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPT
Total quality management ppt for engineering students
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PPTX
introduction to high performance computing
Exploratory_Data_Analysis_Fundamentals.pdf
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Feature types and data preprocessing steps
Design Guidelines and solutions for Plastics parts
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
III.4.1.2_The_Space_Environment.p pdffdf
Fundamentals of Mechanical Engineering.pptx
Abrasive, erosive and cavitation wear.pdf
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Total quality management ppt for engineering students
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Fundamentals of safety and accident prevention -final (1).pptx
August -2025_Top10 Read_Articles_ijait.pdf
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
introduction to high performance computing
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