summaryrefslogtreecommitdiff
path: root/src/sub1sp.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-24 14:53:32 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-24 14:53:32 +0000
commit2bacaa81c07fd0ed1a3e42e5e32e8205a6715a1d (patch)
tree369dd7e0fe7c3cee8ec20cc07c2030f6c8b600a5 /src/sub1sp.c
parent630d243de77e4af18d0f16b5ea5cbc471bb5fe7c (diff)
downloadmpfr-2bacaa81c07fd0ed1a3e42e5e32e8205a6715a1d.tar.gz
[src/sub1sp.c] simplified the computation of sbb
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13023 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sub1sp.c')
-rw-r--r--src/sub1sp.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/sub1sp.c b/src/sub1sp.c
index be72a4e90..2944ce877 100644
--- a/src/sub1sp.c
+++ b/src/sub1sp.c
@@ -1584,6 +1584,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
/* the round bit is in tp[kx], at position sx */
MPFR_ASSERTD(p >= d);
rb = tp[kx] & (MPFR_LIMB_ONE << sx);
+
/* Now compute rbb: since d >= 2 it always exists in C */
if (sx == 0) /* rbb is in the next limb */
{
@@ -1593,17 +1594,11 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
else
sx --; /* rb and rbb are in the same limb */
rbb = tp[kx] & (MPFR_LIMB_ONE << sx);
- /* Look at the last bits of limb kx (If sx=0, does nothing)*/
- if (tp[kx] & MPFR_LIMB_MASK(sx))
- sbb = 1;
- else
- {
- /*kx += (sx==0);*/ /*If sx==0, tp[kx] hasn't been checked*/
- do
- kx--;
- while (kx >= 0 && tp[kx] == 0);
- sbb = kx >= 0;
- }
+
+ /* Now look at the remaining low bits of C to determine sbb */
+ sbb = tp[kx] & MPFR_LIMB_MASK(sx);
+ while (sbb == 0 && kx > 0)
+ sbb = tp[--kx];
}
/* printf("sh=%lu Cp=%d C'p+1=%d\n", sh, rb!=0, sb!=0); */