Graphics Reference
In-Depth Information
Table 11.3 Numbers rounded to one decimal digit under the four rounding modes supported
by the IEEE-754 standard.
Number
Toward Nearest
Toward −Infinity
Toward +Infinity
Toward Zero
1.35
1.4
1.4
1.3
1.3
1.25
1.2
1.3
1.2
1.2
1.25
1.2
1.2
1.3
1.2
1.35
1.4
1.3
1.4
1.3
result when the guard bits alone are not sufficient. The three extra bits are used only
internally during computations and are not stored.
The standard describes four rounding modes: round toward nearest (rounding
toward the nearest representable number, breaking ties by rounding to the even
number), round toward negative infinity (always rounding down), round toward positive
infinity (always rounding up), and round toward zero (truncating, or chopping, the
extra bits). Table 11.3 presents examples of the rounding of some numbers under
these rounding modes.
The error introduced by rounding is bounded by the value known as the machine
epsilon (or unit round-off error ). The machine epsilon is the smallest nonzero machine-
representable number that added to 1 does not equal 1. Specifically, if fl ( x ) denotes
the mapping of the real number x to the nearest floating-point representation it can
be shown that
fl ( x )
=
x (1
+ ε
),
| ε |≤
u ,
where u is the machine epsilon. For single precision, machine epsilon is 2 23
10 16 . These values are in C
and C++ defined as the constants FLT_EPSILON and DBL_EPSILON , respectively. They
can be found in <float.h> for C and in <climits> for C++. The machine epsilon can
be used to estimate errors in floating-point calculations.
An in-depth presentation of floating-point numbers and related issues is given
in [Goldberg91]. In the following, floating-point numbers are assumed IEEE-754
single-precision numbers unless otherwise noted.
10 7 , and for double precision 2 52
1.1921
·
2.2204
·
11.2.2 Infinity Arithmetic
In addition to allowing representation of real numbers, the IEEE-754 standard
also introduces the quasi-numbers negative infinity , positive infinity ,
and NaN
 
Search WWH ::




Custom Search