HP-UX Floating-Point Guide
Chapter 3 91
Factors that Affect the Results of Floating-Point Computations
Floating-Point Coding Practices that Affect Application Results
One way to minimize this kind of precision loss, if you can tolerate the
added execution time, is to sort the elements of an array in ascending
order before you add them together.
Unintentional Underflow
An underflow may occur when a calculation produces a result that is
smaller in magnitude than the smallest normalized value. Sometimes a
calculation can lose virtually all significance when it underflows, yielding
a denormalized value that is then used in subsequent operations.
Suppose that the minimum decimal exponent of a system is −5, and that
A is assigned the value 1.23456789E−3. Then the expression A/1.0E8
would underflow, as Figure 3-3 shows.
Figure 3-3 Unintentional Underflow
Six significant digits are lost during the division, and they cannot be
recovered by scaling the quotient back into the normalized range.
As another example, suppose the familiar form of the Pythagorean
theorem is coded as
Z = SQRT(X**2 + Y**2)
Suppose further that this expression is executed using the following
values for the single-precision variables X and Y:
X = 0.95830116E-20
Y = 0.25553963E-20
These values, when squared, produce the values 9.1834095E−41 and
6.5300508E−42 respectively, whose single-precision representations in
hexadecimal are
0000ffff
00001234