Professional Documents
Culture Documents
Computer Arithmetic
5.1 INTRODUCTION
Because electronic logic deals with currents that are on or off, it has been found convenient to
represent quantities in binary form to perform arithmetic on a computer. Thus, instead of having
ten different digits, 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, in binary arithmetic, there are only two different
digits, 0 and 1, and when moving to the next column, instead of the digit representing a quantity
that is ten times as large, it only represents a quantity that is two times as large. Thus, the first
few numbers are written in binary as follows:
Decimal
Zero
0
One
1
Two
2
Three
3
Four
4
Five
5
Six
6
Seven
7
Eight
8
Nine
9
Ten
10
Eleven 11
Twelve 12
Binary
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
The addition and multiplication tables for binary arithmetic are very small, and this makes it
possible to use logic circuits to build binary adders.
+|0 1
--------0|0 1
1 | 1 10
*|0 1
--------0|0 0
1|0 1
Thus, from the table above, when two binary digits, A and B are added, the carry bit is simply (A
AND B), while the last digit of the sum is more complicated; ((A AND NOT B) OR ((NOT A)
AND B)) is one way to express it.
5.2 Number Systems
In
decimal
system,
a
number
84,
e.g.,
means
84 = (8x10) + 3
4728 = (4x1000)+(7x100)+(2x10)+8
Base or radix of 10: each digit in the number is multiplied by 10 raised to a power
corresponding to that digits position
E.g. 83 = (8x101)+ (3x100)
4728 = (4x103)+(7x102)+(2x101)+(8x100)
Decimal number system
X = i xi10i
of
}
+3 = 00000011
+2 = 00000010
+1 = 00000001
+0 = 00000000
-1 = 11111111
-2 = 11111110
-3 = 11111101
Benefits
5.4
Multiplication
Complex
Work out partial product for each digit
Take care with place value (column)
Add partial products
Multiplication Example
5.5 Division
Divisor
00001101
1011 10010011
1011
Partial
Remainders
001110
1011
001111
1011
100
Quotient
Dividend
Remainder
Real Numbers
The relative magnitudes (order) of the numbers do not change. Can be treated as integers
for comparison.
5.6.1 Normalization
IEEE 754
FP Arithmetic +/