Information Technology Reference
In-Depth Information
Figure 4.11 Representation of a floating-point number
normally represented as a signed binary fraction, e represents the exponent, and b
represents the base (radix) of the exponent.
Example
Figure 4.11 is a representation of a floating-point number having
m ¼
1 bit. If the value stored in S is 0, the
number is positive and if the value stored in S is 1, the number is negative.
The exponent in the above example, can only represent positive numbers 0
through 255. To represent both positive and negative exponents, a fixed value,
called a bias, is subtracted from the exponent field to obtain the true exponent.
Assume that in the above example a bias
23 bits, e ¼
8 bits, and S (sign bit)
¼
¼
128 is used, then true exponents in
þ
the range
127 (stored as 255 in the
exponent field) can be represented. Based on this representation, the exponent
2
128 (stored as 0 in the exponent field) to
þ
4
can be represented by storing 132 in the exponent field, while the exponent
12
2
can be represented by storing 116 in the exponent field.
Assuming that b ¼
2, then an FP number such as 1.75 can be represented in any
of the forms shown in Figure 4.12.
To simplify performing operations on FP numbers and to increase their precision,
they are always represented in what is called normalized forms. An FP number is
said to be normalized if the leftmost bit of the mantissa is 1. Therefore, among
the three above possible representations for 1.75, the first representation is normal-
ized and should be used.
Since the most significant bit (MSB) in a normalized FP number is always 1, then
this bit is often not stored and is assumed to be a hidden bit to the left of the radix
point, that is, the stored mantissa is 1.m. Therefore, a nonzero normalized number
represents the value (
1) s * (1
: m) * 2 e 128 .
Floating-Point Arithmetic Addition / Subtraction
The difficulty in adding
two FP numbers stems from the fact that they may have different exponents.
Therefore, before adding two FP numbers, their exponents must be equalized, that
is, the mantissa of the number that has smaller magnitude of exponent must be
aligned.
0.111*2 1
+
0
10000001
11100000000000000000000
+0.0111*2 2
0
10000010
01110000000000000000000
+0.00000000000000000000111*2 21
0
10010101
00000000000000000000111
Figure 4.12 Different representation of an FP number
Search WWH ::




Custom Search