The dual of truncation is defined similarly, using the ceiling instead of the floor.
Example: Letand
. Then
,
,
,
and
Note that this value is the smallest 5-exact number not exceeded by.
The negative-precision case is less than intuitive.
PROOF: By Lemma 4.1.7,
and hence, by Lemma 1.1.8,
The next three lemmas list simple properties of away that it shares with trunc.
PROOF: By Lemma 4.1.12,
We have the following bounds on
.
PROOF: By Lemmas 1.1.8 and 4.1.1,
PROOF: By Definitions 5.2.1 and 1.1.1 and Lemma 4.1.1,
The second inequality follows from Definition 4.1.1.
PROOF: By Lemmas 5.2.2 and 5.2.5,
The corollary now follows from Lemma 5.2.6.
Unlike trunc, away is not guaranteed to preserve the exponent of its argument, but the only exception is the case in which a number is rounded up to a power of 2.
PROOF: By Lemma 4.1.7,
PROOF: The first inequality follows from Lemmas 5.2.5 and 4.1.4, and the second from Lemmas 5.2.8 and 4.1.2.
The standard rounding mode properties may now be derived.
PROOF: By Corollary 5.2.10 and Lemma 4.2.6, we may assume that
Consequently, it suffices to observe that
PROOF: According to Lemma 5.2.11, the hypothesis implies that
, and hence Lemma 4.1.2 applies.
PROOF: By Definition 4.2.1 and Lemma 1.1.9,
and hence by Definition 5.2.1 and Lemma 4.1.1,
PROOF: If
, then
by Lemmas 5.2.2 and 5.2.5. Therefore, we may assume that
contradicting Lemma 5.2.6.
PROOF: First suppose
. By Lemma 5.2.5,
. Since
is
-exact by Lemma 5.2.11, Lemma 5.2.14 implies
Now suppose
. By Lemma 5.2.2, we may assume that
.
Thus, since
, we have
and by Lemma 5.2.3,
If
is not
-exact, then
and
are successive
-exact numbers.
PROOF: Let
. Since
,
fp
. Since
and
are both
-exact and
, Lemmas 4.2.14 and 4.2.15 imply that
is
-exact and
. But by
Lemma 5.1.7,
, and therefore, by
Lemma 5.2.14,
.
The next four results correspond to Lemmas 5.1.14, 5.1.15 5.1.16, and 5.1.17 of the preceding section.
PROOF: For the case
, we have
by Definition 4.2.1, and by
Lemmas 4.1.1 and 5.2.1,
PROOF: We may assume
. Consider first the case
In this case,
By Lemma 5.2.8, we need only show that
Thus, we may assume
. By Corollary 5.2.10,
and hence by Lemma 1.1.13,
PROOF: Let
. Since
is
-exact,
Let
PROOF: Let
. Since
is
-exact,
Let
The following result combines Lemmas 5.1.17 and 5.2.20.
PROOF: By Lemmas 5.1.3 and 5.2.3, we may assume that
.
The case
is handled by Lemma 5.1.16. For the case
, Lemmas 5.1.17
and 5.2.20 cover the subcases
and
, respectively.
We turn now to the problem of bit-level implementation of rounding.
Truncation, according to Lemma 5.1.18, is equivalent to a
bit slice operation, which may be implemented as a logical operation
using Corollary 5.1.19. Other rouding modes may be reduced to the
case of truncation by a method known as constant injection. Let
be
-exact with
, say
to be rounded to
The appropriate constant for the case
which consists of a string of 1's at the bit positions corresponding to the least significant
As suggested by the diagram, the addition
generates a
carry into the position of
unless
, i.e., unless
is
-exact, and
is rounded up
accordingly. This observation is formalized by the following lemma.
PROOF: Let
. Since
and
are both
-exact and
If
is
-exact, then
, and hence
. Thus, we may
assume
is not
-exact. But then since
and
is
-exact,
and hence
which implies