Graphics Reference
In-Depth Information
0
Figure 11.1 Fixed-point numbers are equally spaced on the number line.
For example, 1/3 can be represented as the 16.16 fixed-point number 21846 (2 16 /3) or
the 8.24 fixed-point number 5592405 (2 24 /3). As a consequence, fixed-point numbers
are equally spaced on the number line (Figure 11.1). With fixed-point numbers there
is a trade-off between the range over which the numbers may span and the precision
with which the fractional part may be given. If numbers are known to be in a limited
range around zero, fixed-point numbers allow high fractional precision (and thus
potentially high accuracy).
In contrast, the decimal point of a floating-point number is not fixed at any given
position but is allowed to“float”as needed. The floating of the decimal point is accom-
plished by expressing numbers in a normalized format similar to scientific notation. In
scientific notation, decimal numbers are written as a number c (the coefficient), with
an absolute value in the range 1
≤|
c
| <
10 multiplied by 10 to some (signed) integer
power. For example:
10 3
8174.12
=
8.17412
·
10 1
12.345
=−
1.2345
·
10 5
0.0000724
=
7.24
·
Floating-point representations are generally not decimal but binary.
Thus,
2 e . Here, f corre-
sponds to a number of fractional bits and e is called the exponent . For example,
(nonzero) numbers are instead typically given in the form
±
(1. f )
8.75
2 3 . The 1. f part is referred to as the mantissa or
significand . The f term alone is sometimes also called the fraction . For this format, the
number 0 is handled as a special case (as discussed in the next section).
Floating-point values are normalized to derive several benefits. First, each number
is guaranteed a unique representation and thus there is no confusion whether 100
should be represented as, say, 10
would be represented as
1.00011
10 3 . Second, leading zeroes in
a number such as 0.00001 do not have to be represented, giving more precision for
small numbers. Third, as the leading bit before the fractional part is always 1, it does
not have to be stored, giving an extra bit of mantissa for free.
Unlike fixed-point numbers, for floating-point numbers the density of rep-
resentable numbers varies with the exponent, as all (normalized) numbers are
represented using the same number of mantissa bits. On the number line, the spac-
ing between representable numbers increases the farther away from zero a number
is located (Figure 11.2). Specifically, for a binary floating-point representation the
10 1 ,1
10 2 , or 0.1
·
·
·
Search WWH ::




Custom Search