The most basic rounding mode, which the IEEE standard calls “round
toward 0”, may be described as a three-step operation on the significand of
its first argument. Thus,
has the same sign and exponent as
,
while its significand is computed from
as follows:
Example: Letand
. Then
,
,
,
and
Note that this value is the largest 5-exact number that does not exceed.
Although the second argument of trunc is normally positive, the following lemma is occasionally useful.
PROOF: By Lemma 4.1.7,
which implies
Like all rounding modes, trunc preserves sign.
This particular mode also has the property of oddness, which, as we shall see, is not common to all IEEE modes.
All of the modes that we shall consider commute with the shift operation.
PROOF: By Lemma 4.1.12,
The inequality stated in the next lemma is the defining characteristic of trunc as a rounding mode.
PROOF: By Definition 1.1.1 and Lemma 4.1.1,
As we have noted, trunc also preserves exponent. This may be proved as a consequence of Lemma 5.1.5.
PROOF: Since
,
by Lemma 4.1.4. But by Lemmas 4.1.7 and 1.1.5,
and hence, by Lemma 4.1.2,
The following inequality complements Lemma 5.1.5, confining
to an interval.
PROOF: By Definitions 5.1.1 and 1.1.1 and Lemma 4.1.1,
The second inequality follows from Definition 4.1.1..
PROOF: By Lemmas 5.1.2 and 5.1.5,
The corollary now follows from Lemma 5.1.7.
With the next four lemmas, we establish trunc as a true rounding mode, as defined by the axioms listed at the beginning of this chapter.
PROOF: Since
, it suffices to observe that
PROOF: According to Lemma 5.1.9, the hypothesis implies that
, and hence Lemma 4.1.2 applies.
PROOF: By Definition 4.2.1 and Lemma 1.1.1,
and hence by Definition 5.1.1 and Lemma 4.1.1,
PROOF: If
, then
by Lemma 5.1.5. Therefore,
we may assume that
.
Suppose
. Then by Lemma 4.2.15,
contradicting Lemma 5.1.7.
PROOF: First suppose
. By Lemma 5.1.5,
. Since
is
-exact by Lemma 5.1.9, Lemma 5.1.12 implies
Now suppose
. By Lemma 5.1.2, we may assume that
.
Thus, since
, we have
and by Lemma 5.1.3,
If
is
-exact but not
-exact, then
is equidistant from two successive
-exact numbers. In this case, we have an explicit formula for
.
PROOF: For the case
, we have
by Definition 4.2.1, and by
Lemmas 4.1.1 and 5.1.1,
Thus, we may assume
Let
and
. Since
,
by Lemma 4.2.15, and hence
and
. It follows that
fp
.
By hypothesis,
but
, and
therefore,
is odd. Let
. Then
Thus,
The following lemma states an intuitively obvious property of truncation, which may be derived directly from Definition 5.1.1.
PROOF: We assume
; the case
follows easily from Lemma 5.1.3.
Applying Lemma 1.1.7, we have
Figure 5.1 is provided as a visual aid in understanding the following lemma, which formulates the precise conditions under which a truncated sum may be computed by truncating one of the summands in advance of the addition.
PROOF: Let
. Since
is
-exact,
Let
PROOF: Let
. Since
is
-exact,
Let
Truncation of a bit vector may be described in terms of the bit slice operator.
PROOF: By Lemmas 2.2.11 and 2.2.13,
PROOF: By Lemmas 5.1.18 and 3.2.18,
But since
PROOF: By Lemmas 5.1.18 and2.2.19,