summaryrefslogtreecommitdiff
path: root/src/div.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-28 20:26:21 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-28 20:26:21 +0000
commitaeb267c49e659d1b9308b744930cf4726877eeb9 (patch)
treed7b216918e8e76ba1004a426447fc65001b43b12 /src/div.c
parent1b20fa13ea26f6da22860ceb51ca0473d268737e (diff)
downloadmpfr-aeb267c49e659d1b9308b744930cf4726877eeb9.tar.gz
[src/div.c] Avoid an infinite recursion when MPFR_LONG_WITHIN_LIMB
is not defined (mpfr_div calls mpfr_div_ui, which calls mpfr_div). [src/div_ui.c] Made the preprocessor test on MPFR_LONG_WITHIN_LIMB consistent with the ones in the other .c files. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13067 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/div.c')
-rw-r--r--src/div.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/div.c b/src/div.c
index ed95101ac..4c751c3b1 100644
--- a/src/div.c
+++ b/src/div.c
@@ -864,12 +864,14 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode)
* *
**************************************************************************/
- /* when the divisor has one limb, we can use mpfr_div_ui, which should be
- faster, assuming there is no intermediate overflow or underflow.
+ /* When the divisor has one limb and MPFR_LONG_WITHIN_LIMB is defined,
+ we can use mpfr_div_ui, which should be faster, assuming there is no
+ intermediate overflow or underflow.
The divisor interpreted as an integer satisfies
2^(GMP_NUMB_BITS-1) <= vm < 2^GMP_NUMB_BITS, thus the quotient
satisfies 2^(EXP(u)-1-GMP_NUMB_BITS) < u/vm < 2^(EXP(u)-GMP_NUMB_BITS+1)
and its exponent is either EXP(u)-GMP_NUMB_BITS or one more. */
+#ifdef MPFR_LONG_WITHIN_LIMB
if (vsize <= 1 && __gmpfr_emin <= MPFR_EXP(u) - GMP_NUMB_BITS
&& MPFR_EXP(u) - GMP_NUMB_BITS + 1 <= __gmpfr_emax
&& vp[0] <= ULONG_MAX)
@@ -892,6 +894,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode)
MPFR_EXP(q) += GMP_NUMB_BITS;
return mpfr_check_range (q, inex, rnd_mode);
}
+#endif
MPFR_TMP_MARK(marker);