Computer Arithmetic
Computer Arithmetic
UNIT 7
COMPUTER ARITHMETIC
Outline
• Introduction
• Addition and subtraction
• Multiplication Algorithms (Booth Multiplication
Algorithm)
• Division Algorithms
• Floating Point Arithmetic operations
• Decimal Arithmetic Unit
1
5/6/2017
Introduction
• Based on the number system two basic data types are implemented
in the computer system: fixed point number and floating point
number.
2
5/6/2017
GTU Questions
1. Explain addition and subtraction operations with signed 2’s
complement integer data. Support your answer by taking
appropriate example(s).
3
5/6/2017
Addition and
substraction
4
5/6/2017
5
5/6/2017
• 0 in E indicates that A < B. For this case it is necessary to take the 2's
complement of the value in A. The operation can be done with one
micro-operation A A' +1.
• The final result is found in register A and its sign in As. The value
in AVF provides an overflow indication. The final value of E is
immaterial.
6
5/6/2017
7
5/6/2017
GTU Questions
Booth Multiplication
Algorithm
8
5/6/2017
Booth’s Algorithm
• Booth algorithm gives a procedure for multiplying binary integers
in signed- 2’s complement representation.
• For example, the binary number 001110 (+14) has a string 1’s
from 23 to 21 (k=3, m=1).
Booth’s Algorithm
9
5/6/2017
Booth’s Algorithm
• Thus the product can be obtained by shifting the binary multiplicand
M four times to the left and subtracting M shifted left once.
Booth’s Algorithm
• The algorithm works for positive or negative multipliers in 2’s
complement representation.
• If the two bits are equal to 10, it means that the first 1 in a
string of 1 's has been encountered. This requires a subtraction
of the multiplicand from the partial product in AC.
10
5/6/2017
Booth’s Algorithm
• If the two bits are equal to 01, it means that the first 0 in a
string of 0's has been encountered. This requires the addition of
the multiplicand to the partial product in AC.
• When the two bits are equal, the partial product does not
change.
Exercise: Multiply the (7) with (3) using Booth’s algorithm. Give
each step.
11
5/6/2017
12
5/6/2017
13
5/6/2017
14
5/6/2017
GTU Questions
3. Multiply the (-9) with (-13) using Booth’s algorithm. Give each
step. (May-14)
15
5/6/2017
Division Algorithm
16
5/6/2017
• In this division process, first the bits of the dividend are examined
from left to right, until the set of bits examined represents a
number greater then or equal to the divisor.
• Until the condition occurs, 0’s are placed in the quotient from left
to right.
• The process continues until all bits of the dividend are brought
down and result is still less than the divisor.
17
5/6/2017
18
5/6/2017
Floating Point
Arithmetic Operation
19
5/6/2017
20
5/6/2017
• If neither of the operands is equal to zero, the process continues with the
exponent addition.
21
5/6/2017
22
5/6/2017
GTU Questions
1. Develop an algorithm for multiplication of two binary numbers,
which are stored as per floating point representation. (June-15,
Dec-16)
23
5/6/2017
Decimal Arithmetic
Unit
BCD Adder
• BCD representation is a class of binary encodings of decimal
numbers where each decimal digit is represented by a fixed
number of bits.
• BCD adder is a circuit that adds two BCD digits in parallel and
produces a sum digit in BCD form.
• Since each input digit does not exceed 9, the output sum cannot be
greater than 19(9+9+1). For example: suppose we apply two BCD
digits to 4-bit binary adder.
• The adder will form the sum in binary and produce a result that
may range from 0 to 19.
24
5/6/2017
BCD Adder
BCD Adder
25
5/6/2017
BCD Adder
• In following figure, these binary numbers are represented by K,
Z8, Z4, Z2, and Z1.
BCD Adder
• The two decimal digits, together with the input-carry, are first
added in the top 4-bit binary adder to produce the binary sum.
When the output-carry is equal to 0, nothing is added to the binary
sum.
26
5/6/2017
GTU Questions
1. Draw the block diagram for BCD adder and explain it. (Dec-14)
27