| Yo, maths buffs,
Below is the code used internally by the rnd / birnd pseudo-random
generators in Aops.c. It uses some floating point algorithm.
For curiosity and documentation purposes I'd like to know its
performance: How many bits does it output - ie, how many
different values? (2^23?)
What length is the cycle?
Where does it come from? etc.
Anybody?
re
static double rndfrac = .5, rndmlt = 105.947;
void rnd1(EVAL *p) /* returns unipolar rand(x) */
{
double intpart;
rndfrac = modf(rndfrac * rndmlt, &intpart);
*p->result = p->ampscale * (FLOAT)rndfrac; |