Graphics Reference
In-Depth Information
Sign (1)
Exponent (8)
Fraction (23)
31
30-23
22-0
Sign (1)
Exponent (11)
Fraction (52)
63
62-52
51-0
Figure 11.3 The IEEE-754 single-precision (top) and double-precision (bottom) floating-point
formats.
In the single-precision floating-point format, floating-point numbers are at the
binary level 32-bit entities consisting of three parts: 1 sign bit ( S ), 8 bits of exponent
( E ), and 23 bits of fraction ( F ) (as illustrated in Figure 11.3). The leading bit of the
mantissa, before the fractional part, is not stored because it is always 1. This bit
is therefore referred to as the hidden or implicit bit. The exponent is also not stored
directly as is. To represent both positive and negative exponents, a bias is added to the
exponent before it is stored. For single-precision numbers this bias is +127. The stored
exponents 0 (all zeroes) and 255 (all ones) are reserved to represent special values
(discussed ahead). Therefore, the effective range for E becomes
126
E
127. All
in all, the value V of a stored IEEE-754 single-precision number is therefore
1) S
2 E 127 .
=
V
(
(1. F )
The IEEE-754 double-precision format is a 64-bit format. It consists of 1 sign bit,
11 bits of exponent, and 52 bits of fraction (Figure 11.3). The exponent is given with
a bias of 1023. The value of a stored IEEE-754 double-precision number is therefore
1) S
2 E 1023 .
V
=
(
(1. F )
With their 8-bit exponent, IEEE-754 single-precision numbers can represent num-
bers of absolute value in the range of approximately 10 38 to 10 38 . The 24-bit
significand means that these numbers have a precision of six to nine decimal dig-
its. The double-precision format can represent numbers of absolute value between
approximately 10 308 and 10 308 , with a precision of 15 to 17 decimal digits. Table 11.1
outlines the representation for a few single-precision floating-point numbers.
Thanks to the bias, floating-point numbers have the useful property that comparing
the bit patterns of two positive floating-point numbers as if they were two 32-bit inte-
gers will give the same Boolean result as a direct floating-point comparison. Positive
floating-point numbers can therefore be correctly sorted on their integer representa-
tion. However, when negative floating-point numbers are involved a signed integer
Search WWH ::




Custom Search