Commit a280b925 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Use the Mersenne Twister as fallback.

2005-06-22  Morten Welinder  <terra@gnome.org>

	* src/mathfunc.c (random_01): Use the Mersenne Twister as
	fallback.
parent a08bb85d
2005-06-22 Morten Welinder <terra@gnome.org>
* src/mathfunc.c (random_01): Use the Mersenne Twister as
fallback.
2005-06-22 Emmanuel Pacaud <emmanuel.pacaud@univ-poitiers.fr>
* src/gnumeric-pane.c (cb_gnm_pane_drag_motion): set snap_to_grid if
......
2005-06-22 Morten Welinder <terra@gnome.org>
* src/mathfunc.c (random_01): Use the Mersenne Twister as
fallback.
2005-06-22 Emmanuel Pacaud <emmanuel.pacaud@univ-poitiers.fr>
* src/gnumeric-pane.c (cb_gnm_pane_drag_motion): set snap_to_grid if
......
......@@ -6506,36 +6506,7 @@ random_01 (void)
device_fd = -1;
}
#ifdef HAVE_RANDOM
{
int r1, r2;
r1 = random () & 2147483647;
r2 = random () & 2147483647;
return (r1 + (r2 / 2147483648.0)) / 2147483648.0;
}
#elif defined (HAVE_DRAND48)
return drand48 ();
#else
{
/*
* We try to work around lack of randomness in rand's
* lower bits.
*/
const int prime = 65537;
int r1, r2, r3, r4;
g_assert (RAND_MAX > ((1 << 12) - 1));
r1 = (rand () ^ (rand () << 12)) % prime;
r2 = (rand () ^ (rand () << 12)) % prime;
r3 = (rand () ^ (rand () << 12)) % prime;
r4 = (rand () ^ (rand () << 12)) % prime;
return (r1 + (r2 + (r3 + r4 / (gnm_float)prime) / prime) / prime) / prime;
}
#endif
return genrand_res53 ();
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment