Integer Arithmetic - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Integer Arithmetic

Description:

... Unsigned Integer Multiplication Flow Diagram 2 s Comp Multiplication Booth s Algorithm 2 s Comp Multiplication Booth s Algorithm 2 s Comp ... – PowerPoint PPT presentation

Number of Views:116
Avg rating:3.0/5.0
Slides: 32
Provided by: Larr155
Category:

less

Transcript and Presenter's Notes

Title: Integer Arithmetic


1
Topics
  • Integer Arithmetic
  • Floating Point Representation
  • Floating Point Arithmetic

2
2s Complement Integers
3
2s Complement Addition/Subtraction
A B ? A
What is Overflow? How is it identified?
4
Unsigned Integer Multiplication
5
Unsigned Integer Multiplication
Q x M ? AQ
6
Unsigned Integer Multiplication Flow Diagram
7
2s Comp MultiplicationBooths Algorithm
Add one extra bit to the Q register
Q-1
8
2s Comp MultiplicationBooths Algorithm
Q-1
9
2s Comp MultiplicationBooths Algorithm
10
Booth (7) x (3)
  • A Q M
  • 3 7
  • 0000 0011 0 0111
  • --------------------
  • 1001 0011 0 0111 A lt- (A - M) 1st
  • 1100 1001 1 0111 Shift
  • --------------------
  • 2nd
  • 1110 0100 1 0111 Shift
  • --------------------
  • 0101 0100 1 0111 A lt- (A M) 3rd
  • 0010 1010 0 0111 Shift
  • --------------------
  • 4th
  • 0001 0101 0 0111 Shift
  • --------------------

11
Booth (7) x (-3)
  • A Q M
  • -3 7
  • 0000 1101 0 0111
  • --------------------
  • 1001 1101 0 0111 A lt- (A - M) 1st
  • 1100 1110 1 0111 Shift
  • --------------------
  • 0011 1110 1 0111 A lt- (A M) 2nd
  • 0001 1111 0 0111 Shift
  • --------------------
  • 1010 1111 0 0111 A lt- (A - M) 3rd
  • 1101 0111 1 0111 Shift
  • --------------------
  • 4th
  • 1110 1011 1 0111 Shift
  • --------------------

12
Booth (-7) x (3)
  • A Q M
  • 3 -7
  • 0000 0011 0 1001
  • --------------------
  • 0111 0011 0 1001 A lt- (A - M) 1st
  • 0011 1001 1 1001 Shift
  • --------------------
  • 2nd
  • 0001 1100 1 1001 Shift
  • --------------------
  • 1010 1100 1 1001 A lt- (A M) 3rd
  • 1101 0110 0 1001 Shift
  • --------------------
  • 4th
  • 1110 1011 0 1001 Shift
  • --------------------

13
Booth (-7) x (-3)
  • A Q M
  • -3 -7
  • 0000 1101 0 1001
  • --------------------
  • 0111 1101 0 1001 A lt- (A - M) 1st
  • 0011 1110 1 1001 Shift
  • --------------------
  • 1100 1110 1 1001 A lt- (A M) 2nd
  • 1110 0111 0 1001 Shift
  • --------------------
  • 0101 0111 0 1001 A lt- (A - M) 3rd
  • 0010 1011 1 1001 Shift
  • --------------------
  • 4th
  • 0001 0101 1 1001 Shift
  • --------------------

14
Unsigned Integer Division
15
Unsigned Integer Division
16
Unsigned Integer Division
17
Unsigned Integer Division
Divisor ? M Dividend ? Q Quotient in
Q Remainder in A
18
What about 2s Comp Division ?
  • Can we do something like Booths Algorithm?
  • Why might we use Booths Algorithm for
    multiplication but not for Division?

19
Single Precision Floating Point NumbersIEEE
Standard
  • 32 bit Single Precision Floating Point Numbers
    are stored as
  • S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
  • S Sign 1 bit
  • E Exponent 8 bits
  • F Fraction 23 bits
  • The value V
  • If E255 and F is nonzero, then V NaN
    ("Not a Number")
  • If E255 and F is zero and S is 1, then V -
    Infinity
  • If E255 and F is zero and S is 0, then V
    Infinity
  • If 0ltElt255 then V (-1)S 2 (E-127)
    (1.F) (exponent range -127 to 128)
  • If E0 and F is nonzero, then V (-1)S 2
    (-126) (0.F) ("unnormalized" values)
  • If E0 and F is zero and S is 1, then V - 0
  • If E0 and F is zero and S is 0, then V 0

Significand
Note 255 decimal 11111111 in binary (8 bits)
20
FP Examples
21
Double Precision Floating Point NumbersIEEE
Standard
  • 64 bit Double Precision Floating Point Numbers
    are stored as
  • S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    FFFFFFFFFFFFFFFFFF
  • S Sign 1 bit
  • E Exponent 11 bits
  • F Fraction 52 bits
  • The value V
  • If E2047 and F is nonzero, then V NaN
    ("Not a Number")
  • If E2047 and F is zero and S is 1, then V -
    Infinity
  • If E2047 and F is zero and S is 0, then V
    Infinity
  • If 0ltElt2047 then V (-1)S 2 (E-1023)
    (1.F) (exponent range -1023 to 1024)
  • If E0 and F is nonzero, then V (-1)S 2
    (-1022) (0.F) ("unnormalized" values)
  • If E0 and F is zero and S is 1, then V - 0
  • If E0 and F is zero and S is 0, then V 0

Significand
Note 2047 decimal 11111111111 in binary (11
bits)
22
32 bit 2s Complement Integer Numbers
All the Integers from -2,147,483,648 to
2,147,483,647, i.e.
- 2 Gig to 2 Gig-1
23
32 bit FP Numbers
24
Density of 32 bit FP Numbers
Note ONLY 232 FP numbers are representable
There are only 232 distinct combinations of
bits in 32 bits !
25
The Added Denormalized FP Numbers
26
Floating Point Addition / Subtraction
  • Steps
  • Check for zero
  • Align the significands (fractions)
  • Add or Subtract the significands
  • Normalize the Result
  • Bad Results
  • Exponent Overflow
  • Exponent Underflow
  • Significand Overflow
  • Significand Underflow

27
Floating Point Addition/Subraction
28
Floating Point Multiplication
  • Check for zero
  • Multiply significands
  • Add exponents
  • Normalize
  • Overflow/underflow?

29
Floating Point Multiplication
30
Floating Point Division
  • Check for zero
  • Divide significands
  • Subract exponents
  • Normalize
  • Overflow/underflow?

31
Floating Point Division
Write a Comment
User Comments (0)
About PowerShow.com