2
2
long runs of consecutive ones and zeros in the binary representation.
3
3
Intended for testing of other MP routines.
5
Copyright 1995, 1996, 2001, 2002 Free Software Foundation, Inc.
5
Copyright 1995, 1996, 2001, 2002, 2003 Free Software Foundation, Inc.
7
7
This file is part of the GNU MP Library.
19
19
You should have received a copy of the GNU Lesser General Public License
20
20
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
21
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22
MA 02111-1307, USA. */
21
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
MA 02110-1301, USA. */
25
25
#include "gmp-impl.h"
29
mpf_random2 (mpf_ptr x, mp_size_t size, mp_exp_t exp)
29
mpf_random2 (mpf_ptr x, mp_size_t xs, mp_exp_t exp)
32
mp_size_t prec = x->_mp_prec;
41
mpn_random2 (x->_mp_d, asize);
46
_gmp_rand (&elimb, RANDS, GMP_NUMB_BITS);
47
exp = elimb % (2 * exp) - exp;
49
x->_mp_exp = asize == 0 ? 0 : exp;
50
x->_mp_size = size < 0 ? -asize : asize;
48
/* General random mantissa. */
49
mpn_random2 (PTR(x), xn);
51
/* Generate random exponent. */
52
_gmp_rand (&elimb, RANDS, GMP_NUMB_BITS);
54
exp = elimb % (2 * exp + 1) - exp;
57
SIZ(x) = xs < 0 ? -xn : xn;