summaryrefslogtreecommitdiff
path: root/mpz/cfdiv_r_2exp.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2015-09-27 06:58:37 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2015-09-27 06:58:37 +0200
commit636b47cba0e80667f4be24783a8c86cf756b788b (patch)
tree8dc12942f894f4c8ccadb090643f6778d56d713a /mpz/cfdiv_r_2exp.c
parent15c72b0ec16d42030056f8cd93069d18fa8dab56 (diff)
downloadgmp-636b47cba0e80667f4be24783a8c86cf756b788b.tar.gz
mpz/cfdiv_r_2exp.c: Use mpn_neg and MPZ_NEWALLOC.
Diffstat (limited to 'mpz/cfdiv_r_2exp.c')
-rw-r--r--mpz/cfdiv_r_2exp.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/mpz/cfdiv_r_2exp.c b/mpz/cfdiv_r_2exp.c
index 5466691f2..0c8abeae3 100644
--- a/mpz/cfdiv_r_2exp.c
+++ b/mpz/cfdiv_r_2exp.c
@@ -73,12 +73,12 @@ cfdiv_r_2exp (mpz_ptr w, mpz_srcptr u, mp_bitcnt_t cnt, int dir)
/* if already smaller than limb_cnt then do nothing */
if (abs_usize <= limb_cnt)
return;
- wp = PTR(w);
+ wp = up;
}
else
{
i = MIN (abs_usize, limb_cnt+1);
- wp = MPZ_REALLOC (w, i);
+ wp = MPZ_NEWALLOC (w, i);
MPN_COPY (wp, up, i);
/* if smaller than limb_cnt then only the copy is needed */
@@ -118,14 +118,10 @@ cfdiv_r_2exp (mpz_ptr w, mpz_srcptr u, mp_bitcnt_t cnt, int dir)
/* Ones complement */
i = MIN (abs_usize, limb_cnt+1);
- mpn_com (wp, up, i);
+ ASSERT_CARRY (mpn_neg (wp, up, i));
for ( ; i <= limb_cnt; i++)
wp[i] = GMP_NUMB_MAX;
- /* Twos complement. Since u!=0 in the relevant part, the twos
- complement never gives 0 and a carry, so can use MPN_INCR_U. */
- MPN_INCR_U (wp, limb_cnt+1, CNST_LIMB(1));
-
usize = -usize;
}