CH08.2-Computer Arithmetic
CH08.2-Computer Arithmetic
+ 3 4
Based on the use of simple digital logic devices that can store
binary digits and perform simple Boolean logic operations
1
+ 5
Sign-Magnitude Representation
6
Integer Representation
There are several alternative •All of these alternatives involve treating the
most significant (leftmost) bit in the word as a
In the binary number system arbitrary numbers can be conventions used to represent sign bit
negative as well as positive •If the sign bit is 0 the number is positive
represented with: integers •If the sign bit is 1 the number is negative
7
Table 10.2 8
Alternative Representations for 4-Bit Integers
Table 10.1
Characteristics of Twos Complement Representation and Arithmetic
2
9
+ 10
Range Extension
11
+ 12
3
+ 13
+ 14
-(-128) = -128 X
Overflow is ignored, so:
Monitor MSB (sign bit)
-0=0
It should change during negation
15 16
Overflow
OVERFLOW RULE:
4
17 18
Subtraction
SUBTRACTION RULE:
19 20
5
21 22
23 24
6
25 26
27 28
7
29 30
31
+ 32
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
8
33
+ 34
Floating-Point
Significand
The final portion of the word
Normal number
The most significant digit of the significand is nonzero
35 36
9
IEEE Standard 754 37
+ 38
IEEE 754-2008
Standard was developed to
facilitate the portability of Defines the following different types of floating-point formats:
programs from one Arithmetic format
Most important floating-point
processor to another and to
representation is defined All the mandatory operations defined by the standard are supported
encourage the development by the format. The format may be used to represent floating-point
of sophisticated, numerically operands or results for the operations described in the standard.
oriented programs
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
Standard has been widely implemented in any conforming implementation.
adopted and is used on IEEE 754-2008 covers both
Interchange format
virtually all contemporary binary and decimal floating-
processors and arithmetic point representations A fully specified, fixed-length binary encoding that allows data
interchange between different platforms and that can be used for
coprocessors storage.
39 40
Table 10.3 IEEE 754 Format Parameters
10
+ Additional Formats 41 42
Table 10.4
Extended Precision Formats IEEE Formats
Extendable Precision Format
Provide additional bits in the exponent
(extended range) and in the significand
(extended precision) Precision and range are defined
under user control
Lessens the chance of a final result that
has been contaminated by excessive May be used for intermediate
roundoff error calculations but the standard
places no constraint or format or
Lessens the chance of an intermediate length
overflow aborting a computation whose
final result would have been
representable in a basic format
Table 10.5 43 44
11
45 46
Table 10.5
Interpretation of IEEE 754 Floating-Point Numbers (page 3 of 3)
47 48
12
49 50
+ 51
+ 52
13
+ 53 Table 10.7 54
IEEE Standard for Binary Floating-Point Arithmetic Operations that Produce a Quiet NaN
Infinity
For example:
5 + (+ ∞ ) = + ∞ 5÷ (+ ∞ ) = +0
5 - (+ ∞ ) = - ∞ (+ ∞ ) + (+ ∞ ) =+∞
5 + (- ∞ ) = - ∞ (- ∞ ) + (- ∞) =-∞
5 - (- ∞ ) = + ∞ (- ∞ ) - (+ ∞ ) =-∞
5 * (+ ∞ ) = + ∞ (+ ∞ ) - (- ∞ ) =+∞
55
+ Summary
56
Computer
Arithmetic
Chapter 10
Integer arithmetic
ALU
Negation
Integer representation
Addition and subtraction
Sign-magnitude
Multiplication
representation
Division
Twos complement
representation Floating-point arithmetic
Range extension Addition and subtraction
Fixed-point representation Multiplication and division
Floating-point representation Precision consideration
Principles IEEE standard for binary
IEEE standard for binary floating-point arithmetic
floating-point representation
14