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
Ad

More Related Content

What's hot (20)

Two’s complement
Two’s complementTwo’s complement
Two’s complement
mayannpolisticoLNU
 
Floating point representation
Floating point representationFloating point representation
Floating point representation
missstevenson01
 
Booths algorithm for Multiplication
Booths algorithm for MultiplicationBooths algorithm for Multiplication
Booths algorithm for Multiplication
Vikas Yadav
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
Sanjeev Patel
 
Instruction codes and computer registers
Instruction codes and computer registersInstruction codes and computer registers
Instruction codes and computer registers
Sanjeev Patel
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperations
Nitesh Singh
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
gavhays
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processing
Kamal Acharya
 
Instruction code
Instruction codeInstruction code
Instruction code
Dr. Abhineet Anand
 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
Digital System Design
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
pyingkodi maran
 
Computer organisation -morris mano
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris mano
vishnu murthy
 
Input output interface
Input output interfaceInput output interface
Input output interface
Christ University
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recoding
Basit Ali
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
PreethiSureshkumar1
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
Ibrahimcommunication Al Ani
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operations
Lakshya Sharma
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
Elizabeth de Leon Aler
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
Mohammad Bashartullah
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
Anil Pokhrel
 
Floating point representation
Floating point representationFloating point representation
Floating point representation
missstevenson01
 
Booths algorithm for Multiplication
Booths algorithm for MultiplicationBooths algorithm for Multiplication
Booths algorithm for Multiplication
Vikas Yadav
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
Sanjeev Patel
 
Instruction codes and computer registers
Instruction codes and computer registersInstruction codes and computer registers
Instruction codes and computer registers
Sanjeev Patel
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperations
Nitesh Singh
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
gavhays
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processing
Kamal Acharya
 
Computer organisation -morris mano
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris mano
vishnu murthy
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recoding
Basit Ali
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operations
Lakshya Sharma
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
Mohammad Bashartullah
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
Anil Pokhrel
 

Viewers also liked (20)

Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
Buddhans Shrestha
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
IIUI
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
Bảo Hoang
 
09 Arithmetic
09  Arithmetic09  Arithmetic
09 Arithmetic
Jeanie Delos Arcos
 
09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
Sher Shah Merkhel
 
Arithmetic for Computers
Arithmetic for ComputersArithmetic for Computers
Arithmetic for Computers
MD. ABU TALHA
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
Student
 
ALU arithmetic logic unit
ALU  arithmetic logic unitALU  arithmetic logic unit
ALU arithmetic logic unit
Karthik Prof.
 
Arithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsArithmetic Process in Computer Systems
Arithmetic Process in Computer Systems
S N M P Simamora
 
Arithmetic Logic Unit .
Arithmetic Logic Unit .Arithmetic Logic Unit .
Arithmetic Logic Unit .
Deyaa Ahmed
 
arithmetic logic unit
arithmetic logic unitarithmetic logic unit
arithmetic logic unit
Shimak Sharook
 
ALU
ALUALU
ALU
Ramasubbu .P
 
Arithmetic logic units
Arithmetic logic unitsArithmetic logic units
Arithmetic logic units
owaisahmad125
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
Dilum Bandara
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computers
Kumar
 
Love as it is to me
Love as it is to meLove as it is to me
Love as it is to me
prasadpawaskar
 
who-are-you
 who-are-you who-are-you
who-are-you
prasadpawaskar
 
Midterm 1
Midterm 1Midterm 1
Midterm 1
IIUM
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Arkhom Jodtang
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
Adarsh Barnwal
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
IIUI
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
Bảo Hoang
 
Arithmetic for Computers
Arithmetic for ComputersArithmetic for Computers
Arithmetic for Computers
MD. ABU TALHA
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
Student
 
ALU arithmetic logic unit
ALU  arithmetic logic unitALU  arithmetic logic unit
ALU arithmetic logic unit
Karthik Prof.
 
Arithmetic Process in Computer Systems
Arithmetic Process in Computer SystemsArithmetic Process in Computer Systems
Arithmetic Process in Computer Systems
S N M P Simamora
 
Arithmetic Logic Unit .
Arithmetic Logic Unit .Arithmetic Logic Unit .
Arithmetic Logic Unit .
Deyaa Ahmed
 
Arithmetic logic units
Arithmetic logic unitsArithmetic logic units
Arithmetic logic units
owaisahmad125
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
Dilum Bandara
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computers
Kumar
 
Midterm 1
Midterm 1Midterm 1
Midterm 1
IIUM
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Arkhom Jodtang
 
Ad

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

Integer represention
Integer representionInteger represention
Integer represention
Saif Ullah
 
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
 
CS304PC:Computer Organization and Architecture session 22 floating point arit...
CS304PC:Computer Organization and Architecture session 22 floating point arit...CS304PC:Computer Organization and Architecture session 22 floating point arit...
CS304PC:Computer Organization and Architecture session 22 floating point arit...
Guru Nanak Technical Institutions
 
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
Guru Nanak Technical Institutions
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
 
CS304PC:Computer Organization and Architecture Session 17 Complements and fix...
CS304PC:Computer Organization and Architecture Session 17 Complements and fix...CS304PC:Computer Organization and Architecture Session 17 Complements and fix...
CS304PC:Computer Organization and Architecture Session 17 Complements and fix...
Guru Nanak Technical Institutions
 
Digital logic design of 2nd Lecture 2.pdf
Digital logic design of 2nd Lecture 2.pdfDigital logic design of 2nd Lecture 2.pdf
Digital logic design of 2nd Lecture 2.pdf
SherifElGohary7
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Unit 2 Arithmetic
Unit 2 ArithmeticUnit 2 Arithmetic
Unit 2 Arithmetic
Balaji Vignesh
 
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptxUnit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Shwetamaurya36
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
arunachalamr16
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
zorogoh2
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
Sanjay Saluth
 
Unit I-L1 - Basics of Digital Computer Organization and Architecture
Unit I-L1 - Basics of Digital Computer Organization and ArchitectureUnit I-L1 - Basics of Digital Computer Organization and Architecture
Unit I-L1 - Basics of Digital Computer Organization and Architecture
amanseerat89
 
Unit 1 - Introduction to Digital Computer (computer organization.pdf
Unit 1 - Introduction to Digital Computer (computer organization.pdfUnit 1 - Introduction to Digital Computer (computer organization.pdf
Unit 1 - Introduction to Digital Computer (computer organization.pdf
chibunnajoe31
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
Sanjay Saluth
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
Sathishkumar.V
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
MeghadriGhosh4
 
2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt
nashitahalwaz95
 
Integer represention
Integer representionInteger represention
Integer represention
Saif Ullah
 
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
 
CS304PC:Computer Organization and Architecture session 22 floating point arit...
CS304PC:Computer Organization and Architecture session 22 floating point arit...CS304PC:Computer Organization and Architecture session 22 floating point arit...
CS304PC:Computer Organization and Architecture session 22 floating point arit...
Guru Nanak Technical Institutions
 
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
Guru Nanak Technical Institutions
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
 
CS304PC:Computer Organization and Architecture Session 17 Complements and fix...
CS304PC:Computer Organization and Architecture Session 17 Complements and fix...CS304PC:Computer Organization and Architecture Session 17 Complements and fix...
CS304PC:Computer Organization and Architecture Session 17 Complements and fix...
Guru Nanak Technical Institutions
 
Digital logic design of 2nd Lecture 2.pdf
Digital logic design of 2nd Lecture 2.pdfDigital logic design of 2nd Lecture 2.pdf
Digital logic design of 2nd Lecture 2.pdf
SherifElGohary7
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptxUnit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Shwetamaurya36
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
arunachalamr16
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
zorogoh2
 
Unit I-L1 - Basics of Digital Computer Organization and Architecture
Unit I-L1 - Basics of Digital Computer Organization and ArchitectureUnit I-L1 - Basics of Digital Computer Organization and Architecture
Unit I-L1 - Basics of Digital Computer Organization and Architecture
amanseerat89
 
Unit 1 - Introduction to Digital Computer (computer organization.pdf
Unit 1 - Introduction to Digital Computer (computer organization.pdfUnit 1 - Introduction to Digital Computer (computer organization.pdf
Unit 1 - Introduction to Digital Computer (computer organization.pdf
chibunnajoe31
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
Sanjay Saluth
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
Sathishkumar.V
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
MeghadriGhosh4
 
2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt
nashitahalwaz95
 
Ad

More from IIUM (20)

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
IIUM
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
IIUM
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
IIUM
 
Kreydle internship-multimedia
Kreydle internship-multimediaKreydle internship-multimedia
Kreydle internship-multimedia
IIUM
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
IIUM
 
Chap2 practice key
Chap2 practice keyChap2 practice key
Chap2 practice key
IIUM
 
Group p1
Group p1Group p1
Group p1
IIUM
 
Tutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seoTutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seo
IIUM
 
Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009
IIUM
 
03 the htm_lforms
03 the htm_lforms03 the htm_lforms
03 the htm_lforms
IIUM
 
Exercise on algo analysis answer
Exercise on algo analysis   answerExercise on algo analysis   answer
Exercise on algo analysis answer
IIUM
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
IIUM
 
Heaps
HeapsHeaps
Heaps
IIUM
 
Report format
Report formatReport format
Report format
IIUM
 
Edpuzzle guidelines
Edpuzzle guidelinesEdpuzzle guidelines
Edpuzzle guidelines
IIUM
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam Paper
IIUM
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam Paper
IIUM
 
Group assignment 1 s21516
Group assignment 1 s21516Group assignment 1 s21516
Group assignment 1 s21516
IIUM
 
Avl tree-rotations
Avl tree-rotationsAvl tree-rotations
Avl tree-rotations
IIUM
 
Week12 graph
Week12   graph Week12   graph
Week12 graph
IIUM
 
How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
IIUM
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
IIUM
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
IIUM
 
Kreydle internship-multimedia
Kreydle internship-multimediaKreydle internship-multimedia
Kreydle internship-multimedia
IIUM
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
IIUM
 
Chap2 practice key
Chap2 practice keyChap2 practice key
Chap2 practice key
IIUM
 
Group p1
Group p1Group p1
Group p1
IIUM
 
Tutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seoTutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seo
IIUM
 
Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009
IIUM
 
03 the htm_lforms
03 the htm_lforms03 the htm_lforms
03 the htm_lforms
IIUM
 
Exercise on algo analysis answer
Exercise on algo analysis   answerExercise on algo analysis   answer
Exercise on algo analysis answer
IIUM
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
IIUM
 
Heaps
HeapsHeaps
Heaps
IIUM
 
Report format
Report formatReport format
Report format
IIUM
 
Edpuzzle guidelines
Edpuzzle guidelinesEdpuzzle guidelines
Edpuzzle guidelines
IIUM
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam Paper
IIUM
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam Paper
IIUM
 
Group assignment 1 s21516
Group assignment 1 s21516Group assignment 1 s21516
Group assignment 1 s21516
IIUM
 
Avl tree-rotations
Avl tree-rotationsAvl tree-rotations
Avl tree-rotations
IIUM
 
Week12 graph
Week12   graph Week12   graph
Week12 graph
IIUM
 

Recently uploaded (20)

Dastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptxDastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptx
omorfaruqkazi
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdfIPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
Quiz Club of PSG College of Arts & Science
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
Conditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture SlideConditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture Slide
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Dastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptxDastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptx
omorfaruqkazi
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 

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