summaryrefslogtreecommitdiff
path: root/src/add1.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-06-03 13:05:57 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-06-03 13:05:57 +0000
commit6344605a1d9860deeedea9773081173351fa82ce (patch)
tree4029cfcc3a353dc45c0ca212eac23f6651adbc01 /src/add1.c
parentc9c5c377ce687f0c1dca19aea9f5464719bd8b06 (diff)
downloadmpfr-6344605a1d9860deeedea9773081173351fa82ce.tar.gz
[src/add1.c] Completed UBF support. Note: due to the restriction
on the exponent values, diff_exp does not need to be the unsigned integer type mpfr_uexp_t (mpfr_exp_t is sufficient). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/ubf@10421 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/add1.c')
-rw-r--r--src/add1.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/add1.c b/src/add1.c
index 437a1d711..37284a9b1 100644
--- a/src/add1.c
+++ b/src/add1.c
@@ -30,9 +30,8 @@ mpfr_add1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
mp_limb_t *ap, *bp, *cp;
mpfr_prec_t aq, bq, cq, aq2;
mp_size_t an, bn, cn;
- mpfr_exp_t difw, exp;
+ mpfr_exp_t difw, exp, diff_exp;
int sh, rb, fb, inex;
- mpfr_uexp_t diff_exp;
MPFR_TMP_DECL(marker);
MPFR_ASSERTD (MPFR_IS_PURE_UBF (b));
@@ -80,9 +79,15 @@ mpfr_add1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
MPFR_SET_SAME_SIGN(a, b);
MPFR_UPDATE2_RND_MODE(rnd_mode, MPFR_SIGN(b));
/* now rnd_mode is either MPFR_RNDN, MPFR_RNDZ or MPFR_RNDA */
- /* Note: exponents can be negative, but the unsigned subtraction is
- a modular subtraction, so that one gets the correct result. */
- diff_exp = (mpfr_uexp_t) exp - MPFR_GET_EXP(c);
+ if (MPFR_UNLIKELY (MPFR_IS_UBF (c)))
+ {
+ MPFR_STAT_STATIC_ASSERT (MPFR_EXP_MAX > MPFR_PREC_MAX);
+ diff_exp = mpfr_ubf_diff_exp (b, c);
+ }
+ else
+ diff_exp = exp - MPFR_GET_EXP (c);
+
+ MPFR_ASSERTD (diff_exp >= 0);
/*
* 1. Compute the significant part A', the non-significant bits of A