summaryrefslogtreecommitdiff
path: root/src/div.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2016-12-30 14:25:47 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2016-12-30 14:25:47 +0000
commit89e194426e772e68d79c401aaa86e186141cb8f3 (patch)
tree1ea5cad4190ffa9bfa8c7b84adca35e3cf09fb37 /src/div.c
parentb0869ce6a6b21e9a9569381f9b383250b4298a63 (diff)
downloadmpfr-89e194426e772e68d79c401aaa86e186141cb8f3.tar.gz
[src/div.c] further improvement in mpfr_div_1()
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11109 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/div.c')
-rw-r--r--src/div.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/div.c b/src/div.c
index f2351df97..25eccae0d 100644
--- a/src/div.c
+++ b/src/div.c
@@ -48,16 +48,16 @@ mpfr_div_1 (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode)
if ((extra = (u0 >= v0)))
u0 -= v0;
-#if GMP_NUMB_BITS == 64 /* __gmpfr_invert_limb only exists for 64-bit for now */
+#if GMP_NUMB_BITS == 64 /* __gmpfr_invert_limb_approx only exists for 64-bit */
/* first try with an approximate quotient */
- mp_limb_t inv = __gmpfr_invert_limb (v0);
+ mp_limb_t inv = __gmpfr_invert_limb_approx (v0);
umul_ppmm (q0, sb, u0, inv);
q0 = (q0 + u0) >> extra;
/* before the >> extra shift, q0 + u0 does not exceed the true quotient
- floor(u'0*2^GMP_NUMB_BITS/v0), with error at most 1, which means the rational
- quotient q satisfies q0 + u0 <= q < q0 + u0 + 2. We can round correctly except
- when the last sh-1 bits of q0 are now 000..000 or 111..111. */
- if (MPFR_LIKELY(((q0 + 1) & (mask >> 1)) > 1))
+ floor(u'0*2^GMP_NUMB_BITS/v0), with error at most 2, which means the rational
+ quotient q satisfies q0 + u0 <= q < q0 + u0 + 3. We can round correctly except
+ when the last sh-1 bits of q0 are 000..000 or 111..111 or 111..110. */
+ if (MPFR_LIKELY(((q0 + 2) & (mask >> 1)) > 2))
{
rb = q0 & (MPFR_LIMB_ONE << (sh - 1));
sb = 1; /* result cannot be exact when we can round with an approximation */