110 likes | 234 Views
Representation of Data (Part II). Computer Studies Notes: chapter 19 Ma King Man. Floating-point number representation. E.g.110.011 (2) can be written as 11.0011 x 2 1 or 1.10011 x 2 2 or 0.11011 x 2 3 (Normalized form). Sign bit. Exponent. Mantissa. Format.
E N D
Representation of Data (Part II) Computer Studies Notes: chapter 19 Ma King Man
Floating-point number representation • E.g.110.011(2) can be written as • 11.0011 x 21 or 1.10011 x 22 or 0.11011 x 23 (Normalized form)
Sign bit Exponent Mantissa Format • The basic format is shown as follow: • Sign bit • Exponent • Mantissa
Note… • Excess 128 method • That is, add 128 to the current value.
Eg 1 • Assume 16-bit word and EXCESS 128 method is used: • 13.125 = 1011.001(ii) • = 0.1011001 x 24 • Fraction = 0.1011001 • Exponent = 4 x 128 • = 132 • = 10000100(ii) • Since the number is positive, therefore the sign bit is 0. Therefore 13.125 will be stored as • 0 10000100 1011001
E.g.2 • -29.75 = -11101.11(ii) • = -0.1110111 x 25 (normalization) • Fraction = 0.1110111 • Fraction = 5 + 128 • = 133 • = 10000101(ii) • Since the number is negative, therefore the sign bit is 1. Therefore –29.75 will be stored as • 1 10000101 1110111
E.g.3 • -0.0625 = -0.0001(ii) • = -0.1 x 2-3 (normalization) • Fraction = 0.1000000 • Exponent = -3 + 128 • = 125 • = 01111101(ii) • Since the number is negative, therefore the sign bit is1. Therefore –0.0625 will be stored as • 1 01111101 1000000
Comparison between fixed-point representation and floating point representation • Range • Fixed-point numbers • Largest positive number = 01111111 11111111 = +32767 • Smallest negative number = 10000000 0000000 = -32768 • Therefore, in 16-bit word storage: • -32768 <= fixed point number <= +32767
Floating-point representation AAssume excess-128 method and 16-bit word is used, a dloating point representation cab have the following values: • Largest positive number = 0 • 11111111 1111111 • 2+127 10+38 • Smallest positive number = 0 • 00000000 1000000 • 2-128 10-39
More… • Largest negative number = 1 0000000 1000000 • 2-128 -10-39 • Smallest negative number = 1 11111111 1111111 • -2+127 -10+38
More…thus… • Therefore, the range of floating number: • -2127 -2-128 , 0 , 2-128 2127 • From the above, we can see that the range of the floating-point representation is wider than that of fixed-point representation.