Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

4-24 Vol. 1
DATA TYPES
The processor then sets the result to b or to c according to the selected rounding
mode. Rounding introduces an error in a result that is less than one unit in the last
place (the least significant bit position of the floating-point value) to which the result
is rounded.
The IEEE Standard 754 defines four rounding modes (see Table 4-8): round to
nearest, round up, round down, and round toward zero. The default rounding mode
(for the Intel 64 and IA-32 architectures) is round to nearest. This mode provides the
most accurate and statistically unbiased estimate of the true result and is suitable for
most applications.
The round up and round down modes are termed directed rounding and can be
used to implement interval arithmetic. Interval arithmetic is used to determine upper
and lower bounds for the true result of a multistep computation, when the interme-
diate results of the computation are subject to rounding.
The round toward zero mode (sometimes called the “chop” mode) is commonly used
when performing integer arithmetic with the x87 FPU.
The rounded result is called the inexact result. When the processor produces an
inexact result, the floating-point precision (inexact) flag (PE) is set (see Section
4.9.1.6, “Inexact-Result (Precision) Exception (#P)”).
The rounding modes have no effect on comparison operations, operations that
produce exact results, or operations that produce NaN results.
4.8.4.1 Rounding Control (RC) Fields
In the Intel 64 and IA-32 architectures, the rounding mode is controlled by a 2-bit
rounding-control (RC) field (Table 4-8 shows the encoding of this field). The RC field
is implemented in two different locations:
x87 FPU control register (bits 10 and 11)
Table 4-8. Rounding Modes and Encoding of Rounding Control (RC) Field
Rounding
Mode
RC Field
Setting Description
Round to
nearest (even)
00B Rounded result is the closest to the infinitely precise result. If two
values are equally close, the result is the even value (that is, the
one with the least-significant bit of zero). Default
Round down
(toward −∞)
01B Rounded result is closest to but no greater than the infinitely
precise result.
Round up
(toward +∞)
10B Rounded result is closest to but no less than the infinitely precise
result.
Round toward
zero (Truncate)
11B Rounded result is closest to but no greater in absolute value than
the infinitely precise result.