diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2000-12-18 09:02:00 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2000-12-18 09:02:00 +0000 |
commit | 9c94b291ca1c5929ce7ca2927f7506045278cdc0 (patch) | |
tree | cb2b32a4711bcfd793f8a30fc60de441bc47ee6c /random2.c | |
parent | 177371d41c4d432af5863e7c053d3e6439e6283d (diff) | |
download | mpfr-9c94b291ca1c5929ce7ca2927f7506045278cdc0.tar.gz |
changed name of mpfr struct fields: _mp_d -> _mpfr_d
(to detect conflicts with mpf)
fixed a few problems in non-STDC headers
moved definitions of mpfr-impl.h to mpfr-test.h and created a real mpfr-impl.h
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@897 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'random2.c')
-rw-r--r-- | random2.c | 28 |
1 files changed, 11 insertions, 17 deletions
@@ -23,22 +23,10 @@ MA 02111-1307, USA. */ #include <stdio.h> #include "gmp.h" -#include "mpfr.h" #include "gmp-impl.h" #include "longlong.h" - - -#if defined (__hpux) || defined (__alpha) || defined (__svr4__) || defined (__SVR4) -/* HPUX lacks random(). DEC OSF/1 1.2 random() returns a double. */ -long mrand48 (); -static long -random () -{ - return mrand48 (); -} -#else -long random (); -#endif +#include "mpfr.h" +#include "mpfr-impl.h" void #if __STDC__ @@ -50,7 +38,9 @@ mpfr_random2 (x, size, exp) mp_exp_t exp; #endif { - mp_size_t xn; unsigned long cnt; mp_ptr xp = MPFR_MANT(x); + mp_size_t xn; + unsigned long cnt; + mp_ptr xp = MPFR_MANT(x), yp[1]; mp_size_t prec = (MPFR_PREC(x) - 1)/BITS_PER_MP_LIMB; MPFR_CLEAR_FLAGS(x); @@ -63,8 +53,12 @@ mpfr_random2 (x, size, exp) mpn_random2 (xp, xn); } - if (exp != 0) - exp = random () % (2 * exp) - exp; + if (exp != 0) { + /* use mpn_random instead of random since that function is not + available on all platforms (for example HPUX, DEC OSF, ...) */ + mpn_random ((mp_limb_t*) yp, 1); + exp = (mp_exp_t) yp[0] % (2 * exp) - exp; + } count_leading_zeros(cnt, xp[xn - 1]); if (cnt) mpn_lshift(xp, xp, xn, cnt); |