CH10 Computer Arithmetic
CH10 Computer Arithmetic
CH10 Computer Arithmetic
William Stallings
Computer Organization
and Architecture
9th Edition
+
Chapter 10
Computer Arithmetic
+
Arithmetic & Logic Unit (ALU)
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 Representation
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
Fixed-Point Representation
+
Negation
Add 1 to LSB + 1
Result 100000000
-0=0
+
Negation Special Case 2
Add 1 to LSB + 1
Result 10000000
So:
-(-128) = -128 X
OVERFLOW RULE:
SUBTRACTION RULE:
Hardware
Implementation of
Unsigned Binary
Multiplication
+
Flowchart for
Unsigned Binary
Multiplication
+
Twos Complement Multiplication
+
Comparison
Booth’s
Algorithm
+
Example of Booth’s Algorithm
Examples Using Booth’s Algorithm
Division
+
Flowchart for
Unsigned
Binary Division
+
Example of Restoring Twos
Complement Division
+
Floating-Point Representation
Principles
With a fixed-point notation it is possible to represent a range of
positive and negative integers centered on or near 0
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
Typical 32-Bit Floating-Point Format
+
Floating-Point
Significand
The final portion of the word
Normal number
The most significant digit of the significand is nonzero
+
Expressible Numbers
+
Density of Floating-Point Numbers
IEEE Standard 754
+
IEEE 754-2008
Arithmetic format
All the mandatory operations defined by the standard are supported by the
format. The format may be used to represent floating-point operands or
results for the operations described in the standard.
Basic format
This format covers five floating-point representations, three binary and two
decimal, whose encodings are specified by the standard, and which can be
used for arithmetic. At least one of the basic formats is implemented in any
conforming implementation.
Interchange format
A fully specified, fixed-length binary encoding that allows data interchange
between different platforms and that can be used for storage.
IEEE 754
Formats
Table 10.3
IEEE 754
Format
Parameters
Provide additional bits in the exponent Precision and range are defined
(extended range) and in the significand under user control
(extended precision)
May be used for intermediate
Lessens the chance of a final result that has
calculations but the standard
been contaminated by excessive roundoff
error
places no constraint or format or
length
Lessens the chance of an intermediate
overflow aborting a computation whose final
result would have been representable in a
basic format
Floating-Point
Multiplication
+
Floating-Point
Division
+
Precision Considerations
Guard Bits
+
Precision Considerations
Rounding
IEEE standard approaches:
Round to nearest:
The result is rounded to the nearest representable number.
Round toward +∞ :
The result is rounded up toward plus infinity.
Round toward -∞:
The result is rounded down toward negative infinity.
Round toward 0:
The result is rounded toward zero.
+
Interval Arithmetic
Provides an efficient method for Minus infinity and rounding to
monitoring and controlling errors in plus are useful in
floating-point computations by implementing interval
producing two values for each result
arithmetic
The two values correspond to the lower
and upper endpoints of an interval that
contains the true result Truncation
The width of the interval indicates the Round toward zero
accuracy of the result
Extra bits are ignored
If the endpoints are not representable
then the interval endpoints are rounded Simplest technique
down and up respectively
A consistent bias toward zero in the
If the range between the upper and operation
lower bounds is sufficiently narrow Serious bias because it affects every
then a sufficiently accurate result has
operation for which there are
been obtained
nonzero extra bits
+
IEEE Standard for Binary Floating-Point Arithmetic
Infinity
Is treated as the limiting case of real arithmetic, with the infinity values
given the following interpretation:
For example:
5 + (+ ∞ ) = + ∞ 5÷ (+ ∞ ) = +0
5 - (+ ∞ ) = - ∞ (+ ∞ ) + (+ ∞ ) =+∞
5 + (- ∞ ) = - ∞ (- ∞ ) + (- ∞) =-∞
5 - (- ∞ ) =+∞ (- ∞ ) - (+ ∞ ) =-∞
5 * (+ ∞ ) = + ∞ (+ ∞ ) - (- ∞ ) =+∞
+IEEE Standard for Binary Floating-Point Arithmetic
Quiet and Signaling NaNs
Signaling NaN signals an invalid operation exception whenever it
appears as an operand
Table 10.7