summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-20 09:17:15 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-20 09:17:15 +0000
commitac7544547377b4c7c828565635614581d279f8d6 (patch)
treeb75e1935a28f1462698baa73e930333de64360b5 /src
parent10c6abfd3980ebe1bc01d137b0d265279e5ee9c3 (diff)
downloadmpfr-ac7544547377b4c7c828565635614581d279f8d6.tar.gz
[src/mul.c] resolved FIXME and removed dead code
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12332 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r--src/mul.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mul.c b/src/mul.c
index df2e6c200..3da233e9b 100644
--- a/src/mul.c
+++ b/src/mul.c
@@ -851,7 +851,7 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
if (MPFR_UNLIKELY (b1 == 0))
mpn_lshift (tmp, tmp, tn, 1); /* tn <= k, so no stack corruption */
}
- else
+ else /* bn >= cn and bn >= 3 */
/* Mulders' mulhigh. This code can also be used via mpfr_sqr,
hence the tests b != c. */
if (MPFR_UNLIKELY (cn > (threshold = b != c ?
@@ -944,9 +944,27 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
}
if (b != c)
{
+#if GMP_NUMB_BITS <= 32
if (cn > n)
- cp --; /* FIXME: Could this happen? */
+ cp --; /* This can only happen on a 32-bit computer,
+ and is very unlikely to happen.
+ Indeed, since n = MIN (an + 1, cn), with
+ an = MPFR_LIMB_SIZE(a), we can have cn > n
+ only when n = an + 1 < cn.
+ We are in the case aq > p - 5, with
+ aq = PREC(a) = an*W - sh, with W = GMP_NUMB_BITS
+ and 0 <= sh < W, and p = n*W - ceil(log2(n+2)),
+ thus an*W - sh > n*W - ceil(log2(n+2)) - 5.
+ Thus n < an + (ceil(log2(n+2)) + 5 - sh)/W.
+ To get n = an + 1, we need
+ ceil(log2(n+2)) + 5 - sh > W, thus since sh>=0
+ we need ceil(log2(n+2)) + 5 > W.
+ With W=32 this can only happen for n>=2^27-1,
+ thus for a precision of 2^32-64 for a,
+ and with W=64 for n>=2^59-1, which would give
+ a precision >= 2^64. */
else
+#endif
{
cp = MPFR_TMP_LIMBS_ALLOC (n + 1);
cp[0] = 0;