Академический Документы
Профессиональный Документы
Культура Документы
Numerical Methods
2. Number Representation
SE301_04 (c)Al-AMER2003 1
Outlines
Number Representation
Normalized Floating Point
Representation
Rounding and Chopping
SE301_04 (c)Al-AMER2003 2
Representing Real Numbers
You are familiar with the decimal system
312.45 = 3 ×10 2 + 1×101 + 2 ×10 0 + 4 ×10 −1 + 5 ×10 −2
SE301_04 (c)Al-AMER2003 3
Normalized Floating Point
Representation
Normalized Floating Point Representation
± 0. d1 d 2 d 3 d 4 × 10 n
sign mantissa exponent
No integral part,
d1 ≠ 0; n : integer
Advantage Efficient in representing very small or very large
numbers
SE301_04 (c)Al-AMER2003 4
Binary System
Binary System Base=2, Digits{0,1}
± 0. 1 b2 b3 b4 × 2 n
sign mantissa exponent
b1 ≠ 0 ⇒ b1 = 1
−1 −2 −3
(0.101) 2 = (1× 2 + 0 × 2 + 1× 2 )10 = (0.625)10
SE301_04 (c)Al-AMER2003 5
Fact
Number that have finite expansion in one numbering
system may have an infinite expansion in another
numbering system
(0.1)10 = (0.000110011001100...) 2
SE301_04 (c)Al-AMER2003 6
Representation
Hypothetical Machine
Mantissa 2 bits exponent 2 bit sign 1 bit
SE301_04 (c)Al-AMER2003 7
Representation
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
SE301_04 (c)Al-AMER2003 8
Remarks
SE301_04 (c)Al-AMER2003 9
Rounding and Choping
SE301_04 (c)Al-AMER2003 10
Remarks
Hypothetical Machine:
32 bits are used to represent
floating point numbers
x − fl ( x) 1 − 23
for any x in the range ≤ (2 )
x 2
SE301_04 (c)Al-AMER2003 11
Error in Representations
for any x in the range
fl ( x) = x(1 + δ ) where δ ≤ 2 − 24
How large can the error be when you multiply two numbers
x * y?
fl(x) = x( 1 + δ1 )
fl ( y ) = y (1 + δ 2 )
fl ( fl ( x) * fl ( y )) = ( x( 1 + δ1 )y (1 + δ 2 ) ) (1 + δ 3 )
SE301_04 (c)Al-AMER2003 12