summaryrefslogtreecommitdiff
path: root/mpz/rrandomb.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2013-02-12 15:41:57 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2013-02-12 15:41:57 +0100
commitf60380ebc78b92d696929cd7da6f7c810d52f21d (patch)
tree37766edbcf0308ae9cb7591bbd1d8d8b5d453123 /mpz/rrandomb.c
parenta48fddf29870af5f7d62efebafc26697a0e1b09e (diff)
downloadgmp-f60380ebc78b92d696929cd7da6f7c810d52f21d.tar.gz
Use BITS_TO_LIMBS and MPZ_NEWALLOC in random functions.
Diffstat (limited to 'mpz/rrandomb.c')
-rw-r--r--mpz/rrandomb.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mpz/rrandomb.c b/mpz/rrandomb.c
index 3e06e2c70..739d14cc6 100644
--- a/mpz/rrandomb.c
+++ b/mpz/rrandomb.c
@@ -30,10 +30,10 @@ mpz_rrandomb (mpz_ptr x, gmp_randstate_t rstate, mp_bitcnt_t nbits)
mp_size_t nl;
mp_ptr xp;
- nl = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
+ nl = BITS_TO_LIMBS (nbits);
if (nbits != 0)
{
- xp = MPZ_REALLOC (x, nl);
+ xp = MPZ_NEWALLOC (x, nl);
gmp_rrandomb (xp, rstate, nbits);
}
@@ -58,7 +58,7 @@ gmp_rrandomb (mp_ptr rp, gmp_randstate_t rstate, mp_bitcnt_t nbits)
mp_size_t i;
/* Set entire result to 111..1 */
- i = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS - 1;
+ i = BITS_TO_LIMBS (nbits) - 1;
rp[i] = GMP_NUMB_MAX >> (GMP_NUMB_BITS - (nbits % GMP_NUMB_BITS)) % GMP_NUMB_BITS;
for (i = i - 1; i >= 0; i--)
rp[i] = GMP_NUMB_MAX;