Logo Search packages:      
Sourcecode: pwlib version File versions

unsigned PRandom::Generate (  ) 

Get the next psuedo-random number in sequence. This generates one pseudorandom unsigned integer (32bit) which is uniformly distributed among 0 to 2^32-1 for each call.

Definition at line 139 of file random.cxx.

Referenced by operator unsigned(), and SetSeed().

{
  if (randcnt--)
    return randrsl[randcnt];

  register DWORD a,b,x,y,*m,*mm,*m2,*r,*mend;
  mm=randmem; r=randrsl;
  a = randa; b = randb + (++randc);
  for (m = mm, mend = m2 = m+(RandSize/2); m<mend; )
  {
    rngstep( a<<13, a, b, mm, m, m2, r, x);
    rngstep( a>>6 , a, b, mm, m, m2, r, x);
    rngstep( a<<2 , a, b, mm, m, m2, r, x);
    rngstep( a>>16, a, b, mm, m, m2, r, x);
  }
  for (m2 = mm; m2<mend; )
  {
    rngstep( a<<13, a, b, mm, m, m2, r, x);
    rngstep( a>>6 , a, b, mm, m, m2, r, x);
    rngstep( a<<2 , a, b, mm, m, m2, r, x);
    rngstep( a>>16, a, b, mm, m, m2, r, x);
  }
  randb = b; randa = a;

  randcnt = RandSize-1;
  return randrsl[randcnt];
}


Generated by  Doxygen 1.6.0   Back to index