diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-09-15 01:57:46 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-09-15 01:57:46 +0000 |
commit | 5f7a7b56ea85dc2fda07f6dc6d956400fdc2d597 (patch) | |
tree | 827a1ef6bc2f7c26fa0efff4040f97b965c049a5 /src/urandomb.c | |
parent | 826de944d84c201a8bed38eb3714a9e16997afec (diff) | |
download | mpfr-5f7a7b56ea85dc2fda07f6dc6d956400fdc2d597.tar.gz |
[urandomb.c] added comment + slight change
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7132 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/urandomb.c')
-rw-r--r-- | src/urandomb.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/urandomb.c b/src/urandomb.c index e632ca83d..d8eac64ab 100644 --- a/src/urandomb.c +++ b/src/urandomb.c @@ -27,15 +27,17 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" +/* generate nbits random bits into mp[], assuming mp was allocated to contain + a sufficient number of limbs */ void mpfr_rand_raw (mp_ptr mp, gmp_randstate_t rstate, unsigned long int nbits) { mpz_t z; /* To be sure to avoid the potential allocation of mpz_urandomb */ - ALLOC(z) = SIZ(z) = (nbits / GMP_NUMB_BITS) + 1; + ALLOC(z) = SIZ(z) = ((nbits - 1) / GMP_NUMB_BITS) + 1; PTR(z) = mp; - mpz_urandomb(z, rstate, nbits); + mpz_urandomb (z, rstate, nbits); } int |