summaryrefslogtreecommitdiff
path: root/round_prec.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-09-15 13:05:05 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-09-15 13:05:05 +0000
commit58ea8f3f30acc5b5df5fa9a537be65790958071e (patch)
tree8ba369fbf0352aa846d9d0d22c87ca8202f5488e /round_prec.c
parentd71cf99ec93271eb23df466b55240249324359a3 (diff)
downloadmpfr-58ea8f3f30acc5b5df5fa9a537be65790958071e.tar.gz
Added a test to tests/tcan_round.c and assertions to round_prec.c.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2412 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'round_prec.c')
-rw-r--r--round_prec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/round_prec.c b/round_prec.c
index 9b8bf7e17..b7419a783 100644
--- a/round_prec.c
+++ b/round_prec.c
@@ -213,10 +213,9 @@ mpfr_round_prec (mpfr_ptr x, mp_rnd_t rnd_mode, mp_prec_t prec)
/* assumption: BITS_PER_MP_LIMB is a power of 2 */
-/* assuming b is an approximation of x in direction rnd1
- with error at most 2^(MPFR_EXP(b)-err), returns 1 if one is
- able to round exactly x to precision prec with direction rnd2,
- and 0 otherwise.
+/* assuming b is an approximation to x in direction rnd1 with error at
+ most 2^(MPFR_EXP(b)-err), returns 1 if one is able to round exactly
+ x to precision prec with direction rnd2, and 0 otherwise.
Side effects: none.
*/
@@ -297,6 +296,7 @@ mpfr_can_round_raw (mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0,
cc ^= mpfr_round_raw2(bp, bn, neg, rnd2, prec);
/* now round b +/- 2^(MPFR_EXP(b)-err) */
+ MPFR_ASSERTN (k > 0);
cc2 = rnd1 == GMP_RNDZ ?
mpn_add_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s) :
mpn_sub_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s);
@@ -304,6 +304,7 @@ mpfr_can_round_raw (mp_limb_t *bp, mp_size_t bn, int neg, mp_exp_t err0,
else
{ /* GMP_RNDN */
/* first round b+2^(MPFR_EXP(b)-err) */
+ MPFR_ASSERTN (k > 0);
cc = mpn_add_1 (tmp + bn - k, bp + bn - k, k, MP_LIMB_T_ONE << s);
cc = (tmp[bn - 1] >> s1) & 1; /* gives 0 when cc=1 */
cc ^= mpfr_round_raw2 (tmp, bn, neg, rnd2, prec);