Integer Division, Floating Point Representation, and Arithmetic - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Integer Division, Floating Point Representation, and Arithmetic

Description:

Multiplication: In general, if the multiplicand has n bits and the multiplier ... Multiplicand. Multiplier. Step. Iteration. 2*3. n=4. Example: Multiplication ... – PowerPoint PPT presentation

Number of Views:395
Avg rating:3.0/5.0
Slides: 19
Provided by: egBuc
Category:

less

Transcript and Presenter's Notes

Title: Integer Division, Floating Point Representation, and Arithmetic


1
  • Integer Division, Floating Point Representation,
    and Arithmetic

2
Operations on 2s Complement
Multiplication If the multiplier is a power of
2, the operation is trivial. Otherwise, we have
to define an algorithm.
Example
1011 1110 0000
x
1011
1011
1011

10011010
3
Signing The Result of Unsigned Multiplication and
Division
  • The algorithms well see ahead compute the
    unsigned product or quotient of two operands. To
    do signed multiplication and division, we can
    record the signs of the operands, do the unsigned
    operation and then correct the sign of the result.

4
Multiplication In general, if the multiplicand
has n bits and the multiplier has m bits, the
product will have (nm) bits. Note whats going
on we go through each bit in the multiplier and
performing a sequence of left-shifts and
additions. This is an indication that to
implement multiplication in hardware, one needs a
shift-register and an adder. What about the signs
of the operands and the sign of the result?
5
An Algorithm for Multiplication
Both operands are 32-bits long. What is the
size of the product? How many registers are
needed to implement this in hardware? In
general, how many repetitions are needed by this
algorithm?
6
Simple Multiplication Hardware
7
Example Multiplication
23
n4
8
Example Multiplication
23
n4
9
Another Algorithm for Multiplication
10
Refined Multiplication Hardware
11
Operations on 2s Complement
Division It the multiplier is a power of 2, the
operation is trivial. Otherwise, we have to
define an algorithm, but first, lets think a
little bit. Quotient How many times does the
divisor fit into the dividend? Remainder After
the largest multiple of the divisor that fits in
the dividend has been subtracted from the
dividend, whats left?
12
  • Division

1001
1000
1001010
-1000
1010
-1000
10
We do subtractions and shifts
13
A Simpler (?) Flowchart for the Basic Division
Algorithm
start
1001
RR-D
1000
1001010
yes
no
-1000

1010
-1000
RRD Qltlt1(0)
10
Qltlt1(1)
2n bits
(0)Dgtgt1
D
divisor 0000
no
n1 reps?
R
0000 dividend
yes
Q
0000
done
n bits
14
Simple Division Hardware
15
7 2
n4
16
7 2
n4
17
Refined Division Hardware
18
Signing The Remainder
To avoid such confusion, we postulate
Write a Comment
User Comments (0)
About PowerShow.com