Beruflich Dokumente
Kultur Dokumente
App
App
App
Formats
System software
CIS 371
Computer Organization and Design
Mem
CPU
I/O
Operations
Addition and subtraction
Multiplication and division
Error analysis
Readings
P+H
Two uses
Scientific Notation
Range
Precision
Distance between two consecutive representable numbers
Want small
Number [S,F,E] = S * F * 2E
S: sign
F: significand (fraction)
E: exponent
Floating point: binary (decimal) point has different magnitude
Sign: 0 or 1 ! easy
Exponent: signed integer ! also easy
Significand: unsigned fraction ! ??
Some Examples
Normalized Numbers
Notice
Sign: 0
5 = 1.25 * 22
Significand: 1.25 = 1*20 + 1*22 = 101 0000 0000 0000 0000 0000
Exponent: 2 = 0000 0010
Sign: 1
0.5 = 0.5 * 20
Significand: 0.5 = 1*21 = 010 0000 0000 0000 0000 0000
Exponent: 0 = 0000 0000
5 is 1.25 * 22
But isnt it also 0.625 * 23 and 0.3125 * 24 and ?
With 8-bit exponent, we can have 256 representations of 5
10
12
Sign: 1
0.5 = 1 * 21
Significand: 1 = 1*20 = 100 0000 0000 0000 0000 0000
Exponent: -1 = 1111 1111
13
There are both +0 and 0, but they are considered the same
Also represent numbers smaller than smallest normalized numbers
14
15
N / 0 = infinity
N / infinity = 0
0 / 0 = NaN
Infinity / infinity = NaN
Infinity infinity = NaN
Anything and NaN = NaN
16
significand
Addition/subtraction
Multiplication/division
Biased exponent
Normalized significand
Exponent more significant than significand
Implementation
Basically, integer arithmetic on significand and exponent
Using integer ALUs
Plus extra hardware for normalization
17
FP Addition
Assume
18
9.95*101 + 8.0*10-1
19
20
FP Addition Hardware
E1
F1
E2
ctrl
De-normalize
smaller exponent
>>
v +
>>
F2
21
FP Multiplication
Assume
22
Normalize result
Add significands
23
Normalization
Addition of exponents in biased notation (must subtract bias)
Tricky: when multiplying two normalized significands
Where is the binary point?
24
FP Division
Accuracy
Assume
Normalization
Subtraction of exponents in biased notation (must add bias)
Binary point placement
No need to worry about remainders, either
Solution: round
Ironic
Multiplication/division roughly same complexity for FP and integer
Addition/subtraction much more complicated for FP than integer
CIS371 (Roth/Martin): Floating Point
25
Numerical Analysis
26
28
Arithmetic Latencies
Align exponents
Add/subtract significands
Re-normalize
Round
Potentially re-normalize again
Potentially round again
Int 32
Int 64
Fp 32
Fp 64
Add/Subtract
Multiply
14 to 40
23 to 87
16
20
Divide
29
Summary
App
App
App
FP representation
Scientific notation: S*F*2E
IEEE754 standard
Representing fractions
System software
Mem
CPU
I/O
FP operations
Addition/subtraction: harder than integer
Multiplication/division: same as integer!!
Accuracy problems
Rounding and truncation
Upshot: FP is painful
Thank lucky stars P37X has no FP
31
30