diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-02-12 15:41:57 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-02-12 15:41:57 +0100 |
commit | f60380ebc78b92d696929cd7da6f7c810d52f21d (patch) | |
tree | 37766edbcf0308ae9cb7591bbd1d8d8b5d453123 /mpz/rrandomb.c | |
parent | a48fddf29870af5f7d62efebafc26697a0e1b09e (diff) | |
download | gmp-f60380ebc78b92d696929cd7da6f7c810d52f21d.tar.gz |
Use BITS_TO_LIMBS and MPZ_NEWALLOC in random functions.
Diffstat (limited to 'mpz/rrandomb.c')
-rw-r--r-- | mpz/rrandomb.c | 6 |
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; |