SlideShare a Scribd company logo
Madam Raini Hassan
Office: C5 - 23, Level 5, KICT Building
Department: Computer Science
Emails: hrai@iium.edu.my, hraini.iii@gmail.com
1Semester II 2014/2015
Du’a for Study
Semester II 2014/2015 2
LECTURE 03
Computer
Arithmetic:
Arithmetic and
Logic Unit (ALU)
(Chapter 10)
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 Representations
• 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
Integer Representations
• There are 4 commonly known (1 not common)
integer representations.
• All have been used at various times for various
reasons.
1. Unsigned
2. Sign Magnitude
3. One’s Complement
4. Two’s Complement
5. Biased (not commonly known)
1. Unsigned
• The standard binary encoding already given.
• Only positive value.
• Range: 0 to ((2 to the power of N bits) – 1)
• Example: 4 bits; (2ˆ4)-1 = 16-1 = values 0 to 15
Semester II 2014/2015 8
1. Unsigned (Cont’d.)
Semester II 2014/2015 9
2. Sign-Magnitude
There are several alternative
conventions used to represent
negative as well as positive integers
Sign-magnitude representation is
the simplest form that employs a
sign bit
Drawbacks:
Because of these drawbacks, sign-
magnitude representation is rarely
used in implementing the integer
portion of the ALU
• All of these alternatives involve treating the
most significant (leftmost) bit in the word as
a sign bit
• If the sign bit is 0 the number is positive
• If the sign bit is 1 the number is negative
• Addition and subtraction require a
consideration of both the signs of the
numbers and their relative magnitudes to
carry out the required operation
• There are two representations of 0
2. Sign-Magnitude (Cont’d.)
• It is a human readable way of getting both
positive and negative integers.
• The hardware that does arithmetic on sign
magnitude integers.
• Not fast.
2-11
2. Sign-Magnitude (Cont’d.)
• Left most bit is sign bit
• 0 means positive
• 1 means negative
• +18 = 00010010
• -18 = 10010010
2-12
3. One’s Complement
• Used to get two’s complement integers.
• Nowadays, it is not being applied to any of the
machines.
• Stated in this slide for historical purpose.
Semester II 2014/2015 13
4. Two’s Complement
• Uses the most significant bit as a sign bit
• Differs from sign-magnitude representation in the way that the other
bits are interpreted
Table 10.1 Characteristics of Twos Complement Representation and Arithmetic
5. Biased
• an integer representation that skews the bit
patterns so as to look just like unsigned but
actually represent negative numbers.
Semester II 2014/2015 15
Table 10.2
Alternative Representations for 4-Bit Integers
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
Range of Numbers
• 8 bit 2s complement
– +127 = 01111111 = 27 -1
– -128 = 10000000 = -27
• 16 bit 2s complement
– +32767 = 011111111 11111111 = 215 - 1
– -32768 = 100000000 00000000 = -215
2-18
Negation
• 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
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
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.
Addition
SUBTRACTION RULE:
To subtract one number
(subtrahend) from another
(minuend), take the twos
complement (negation) of
the subtrahend and add it
to the minuend.
Subtraction
Geometric Depiction of Twos
Complement Integers
Hardware for Addition and
Subtraction
Multiplication
Hardware
Implementation
of Unsigned
Binary
Multiplication
Flowchart for
Unsigned Binary
Multiplication
Twos Complement Multiplication
Comparison
Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Division
Flowchart for
Unsigned
Binary Division
Example of Restoring Twos
Complement Division
+
Floating-Point Representation
• With a fixed-point notation it is possible to
represent a range of positive and negative integers
centered on or near 0
• By assuming a fixed binary or radix point, this
format allows the representation of numbers with a
fractional component as well
• Limitations:
– Very large numbers cannot be represented nor can very
small fractions
– The fractional part of the quotient in a division of two
large numbers could be lost
Principles
Typical 32-Bit Floating-Point Format
+
Floating-Point
• The final portion of the word
• Any floating-point number can be expressed in
many ways
• Normal number
– The most significant digit of the significand is
nonzero
Significand
The following are equivalent, where the significand is expressed in
binary form:
0.110 * 25
110 * 22
0.0110 * 26
IEEE Standard 754
Most important floating-point
representation is defined
Standard was developed to
facilitate the portability of
programs from one processor
to another and to encourage
the development of
sophisticated, numerically
oriented programs
Standard has been widely
adopted and is used on
virtually all contemporary
processors and arithmetic
coprocessors
IEEE 754-2008 covers both
binary and decimal floating-
point representations
IEEE 754
Formats
Floating-Point Addition and Subtraction
Floating-Point
Multiplication
Floating-Point
Division

More Related Content

PPTX
Multiplication algorithm
PPT
Booths Multiplication Algorithm
DOCX
Control Units : Microprogrammed and Hardwired:control unit
PPTX
Booths algorithm for Multiplication
PDF
Control Unit Design
PPTX
Addressing mode Computer Architecture
PPTX
Priority Queue in Data Structure
PPTX
Signed Addition And Subtraction
Multiplication algorithm
Booths Multiplication Algorithm
Control Units : Microprogrammed and Hardwired:control unit
Booths algorithm for Multiplication
Control Unit Design
Addressing mode Computer Architecture
Priority Queue in Data Structure
Signed Addition And Subtraction

What's hot (20)

PPTX
Types of Addressing modes- COA
PPTX
Computer arithmetic
PPTX
Arithmetic micro operations
PPTX
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
PPT
17. Recovery System in DBMS
PPTX
Basic Computer Organization and Design
PPTX
Number system in Digital Electronics
PPTX
Error Control In Network Layer
PPT
Sorting network
PPT
Error detection correction (CRC)
PPTX
Microoperations
PPTX
3.codes( binary code ,excess 3, gray code )
PPTX
Addressing sequencing
PPTX
Floating point arithmetic operations (1)
PPTX
Computer arithmetic
PDF
Interconnection Network
PPTX
Floating Point Multiplication.pptx
PPTX
Computer Organization
PPT
Arithmetic circuits
PPT
Instruction Set Architecture (ISA)
Types of Addressing modes- COA
Computer arithmetic
Arithmetic micro operations
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
17. Recovery System in DBMS
Basic Computer Organization and Design
Number system in Digital Electronics
Error Control In Network Layer
Sorting network
Error detection correction (CRC)
Microoperations
3.codes( binary code ,excess 3, gray code )
Addressing sequencing
Floating point arithmetic operations (1)
Computer arithmetic
Interconnection Network
Floating Point Multiplication.pptx
Computer Organization
Arithmetic circuits
Instruction Set Architecture (ISA)
Ad

Viewers also liked (20)

PDF
Chapter 05 computer arithmetic
PPTX
Chapter 03 arithmetic for computers
PPT
09 Arithmetic
PPT
09 arithmetic
PPTX
Arithmetic for Computers
PPT
Arithmetic Logic Unit (ALU)
PPT
ALU arithmetic logic unit
PPS
Arithmetic Process in Computer Systems
PPTX
Arithmetic Logic Unit .
PPTX
arithmetic logic unit
PPT
PPTX
Arithmetic logic units
PPTX
Computer Architecture – An Introduction
PPT
Basic structure of computers
PDF
Love as it is to me
PPS
who-are-you
PDF
Midterm 1
PPTX
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
PPT
Microprocessor
PDF
How to Open a Computer Repair Shop: 8 Steps to Build Your Client List [Slides]
Chapter 05 computer arithmetic
Chapter 03 arithmetic for computers
09 Arithmetic
09 arithmetic
Arithmetic for Computers
Arithmetic Logic Unit (ALU)
ALU arithmetic logic unit
Arithmetic Process in Computer Systems
Arithmetic Logic Unit .
arithmetic logic unit
Arithmetic logic units
Computer Architecture – An Introduction
Basic structure of computers
Love as it is to me
who-are-you
Midterm 1
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor
How to Open a Computer Repair Shop: 8 Steps to Build Your Client List [Slides]
Ad

Similar to Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu) (20)

PDF
Integer represention
PPTX
CH10-COA10e.pptx
PPT
Mba admission in india
PPTX
ALU.pptx kjvjjfjrshfjshfjrhfjershfherjghre
PPTX
module 1_class_numbers.pptx
PPT
Mba admission in india
PPTX
Data Representation.pptx
PPT
Counit2
PPT
09 arithmetic
PPT
09 arithmetic 2
PPT
Digital fundamendals r001a
PPTX
DE -gxgxhxydydydfyfduffuf UEEB02 - L 7.pptx
PPTX
Computer Architecture
PPTX
Computer Architecture
PDF
Notes unit 2
PPT
Arithmetic unit.ppt
PPTX
PDF
DigitalLogic_NumberRepresentation.pdf advanced
PPT
Lecture 3
PPT
Twos_Complement_Binary in Information Technology
Integer represention
CH10-COA10e.pptx
Mba admission in india
ALU.pptx kjvjjfjrshfjshfjrhfjershfherjghre
module 1_class_numbers.pptx
Mba admission in india
Data Representation.pptx
Counit2
09 arithmetic
09 arithmetic 2
Digital fundamendals r001a
DE -gxgxhxydydydfyfduffuf UEEB02 - L 7.pptx
Computer Architecture
Computer Architecture
Notes unit 2
Arithmetic unit.ppt
DigitalLogic_NumberRepresentation.pdf advanced
Lecture 3
Twos_Complement_Binary in Information Technology

More from IIUM (20)

PDF
How to use_000webhost
PDF
Chapter 2
PDF
Chapter 1
PDF
Kreydle internship-multimedia
PDF
03phpbldgblock
PDF
Chap2 practice key
PDF
Group p1
PDF
Tutorial import n auto pilot blogspot friendly seo
PDF
Visual sceneperception encycloperception-sage-oliva2009
PDF
03 the htm_lforms
PDF
Exercise on algo analysis answer
PDF
Redo midterm
PDF
Heaps
PDF
Report format
PDF
Edpuzzle guidelines
PDF
Final Exam Paper
PDF
Final Exam Paper
PDF
Group assignment 1 s21516
PDF
Avl tree-rotations
PDF
Week12 graph
How to use_000webhost
Chapter 2
Chapter 1
Kreydle internship-multimedia
03phpbldgblock
Chap2 practice key
Group p1
Tutorial import n auto pilot blogspot friendly seo
Visual sceneperception encycloperception-sage-oliva2009
03 the htm_lforms
Exercise on algo analysis answer
Redo midterm
Heaps
Report format
Edpuzzle guidelines
Final Exam Paper
Final Exam Paper
Group assignment 1 s21516
Avl tree-rotations
Week12 graph

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Classroom Observation Tools for Teachers
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
01-Introduction-to-Information-Management.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Business Ethics Teaching Materials for college
PDF
Pre independence Education in Inndia.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
RMMM.pdf make it easy to upload and study
102 student loan defaulters named and shamed – Is someone you know on the list?
2.FourierTransform-ShortQuestionswithAnswers.pdf
Classroom Observation Tools for Teachers
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Microbial diseases, their pathogenesis and prophylaxis
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
TR - Agricultural Crops Production NC III.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
01-Introduction-to-Information-Management.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Business Ethics Teaching Materials for college
Pre independence Education in Inndia.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
RMMM.pdf make it easy to upload and study

Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)

  • 1. Madam Raini Hassan Office: C5 - 23, Level 5, KICT Building Department: Computer Science Emails: [email protected], [email protected] 1Semester II 2014/2015
  • 2. Du’a for Study Semester II 2014/2015 2
  • 4. 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
  • 5. ALU Inputs and Outputs
  • 6. Integer Representations • 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
  • 7. Integer Representations • There are 4 commonly known (1 not common) integer representations. • All have been used at various times for various reasons. 1. Unsigned 2. Sign Magnitude 3. One’s Complement 4. Two’s Complement 5. Biased (not commonly known)
  • 8. 1. Unsigned • The standard binary encoding already given. • Only positive value. • Range: 0 to ((2 to the power of N bits) – 1) • Example: 4 bits; (2ˆ4)-1 = 16-1 = values 0 to 15 Semester II 2014/2015 8
  • 10. 2. Sign-Magnitude There are several alternative conventions used to represent negative as well as positive integers Sign-magnitude representation is the simplest form that employs a sign bit Drawbacks: Because of these drawbacks, sign- magnitude representation is rarely used in implementing the integer portion of the ALU • All of these alternatives involve treating the most significant (leftmost) bit in the word as a sign bit • If the sign bit is 0 the number is positive • If the sign bit is 1 the number is negative • Addition and subtraction require a consideration of both the signs of the numbers and their relative magnitudes to carry out the required operation • There are two representations of 0
  • 11. 2. Sign-Magnitude (Cont’d.) • It is a human readable way of getting both positive and negative integers. • The hardware that does arithmetic on sign magnitude integers. • Not fast. 2-11
  • 12. 2. Sign-Magnitude (Cont’d.) • Left most bit is sign bit • 0 means positive • 1 means negative • +18 = 00010010 • -18 = 10010010 2-12
  • 13. 3. One’s Complement • Used to get two’s complement integers. • Nowadays, it is not being applied to any of the machines. • Stated in this slide for historical purpose. Semester II 2014/2015 13
  • 14. 4. Two’s Complement • Uses the most significant bit as a sign bit • Differs from sign-magnitude representation in the way that the other bits are interpreted Table 10.1 Characteristics of Twos Complement Representation and Arithmetic
  • 15. 5. Biased • an integer representation that skews the bit patterns so as to look just like unsigned but actually represent negative numbers. Semester II 2014/2015 15
  • 17. 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
  • 18. Range of Numbers • 8 bit 2s complement – +127 = 01111111 = 27 -1 – -128 = 10000000 = -27 • 16 bit 2s complement – +32767 = 011111111 11111111 = 215 - 1 – -32768 = 100000000 00000000 = -215 2-18
  • 19. Negation • 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
  • 20. Negation Special Case 1 0 = 00000000 (twos complement) Bitwise complement = 11111111 Add 1 to LSB + 1 Result 100000000 Overflow is ignored, so: - 0 = 0
  • 21. 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
  • 22. 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.
  • 24. SUBTRACTION RULE: To subtract one number (subtrahend) from another (minuend), take the twos complement (negation) of the subtrahend and add it to the minuend.
  • 26. Geometric Depiction of Twos Complement Integers
  • 27. Hardware for Addition and Subtraction
  • 36. Example of Restoring Twos Complement Division
  • 37. + Floating-Point Representation • With a fixed-point notation it is possible to represent a range of positive and negative integers centered on or near 0 • By assuming a fixed binary or radix point, this format allows the representation of numbers with a fractional component as well • Limitations: – Very large numbers cannot be represented nor can very small fractions – The fractional part of the quotient in a division of two large numbers could be lost Principles
  • 39. + Floating-Point • The final portion of the word • Any floating-point number can be expressed in many ways • Normal number – The most significant digit of the significand is nonzero Significand The following are equivalent, where the significand is expressed in binary form: 0.110 * 25 110 * 22 0.0110 * 26
  • 40. IEEE Standard 754 Most important floating-point representation is defined Standard was developed to facilitate the portability of programs from one processor to another and to encourage the development of sophisticated, numerically oriented programs Standard has been widely adopted and is used on virtually all contemporary processors and arithmetic coprocessors IEEE 754-2008 covers both binary and decimal floating- point representations