//A RNG testing program, Dale Swanson - Nov 19 2006
#include
#include
#include
#include
using namespace std;
int x;
double y;
int z;
int num[111];
int bit; //counts number of bits gen so far
int byte; //counts number of bytes gen so far
int rann; //will be the ran number returned
int min; //min random number
int max; //max ran number
int word[50]; //will be an arrary the holds the binnary form of our number
int test;
int one, two, sone, stwo;
int powtwo;
int comp;
double ran(double a, double b) //returns a random number between a min, and b max
{
int k; //used for killing some random numbers (k is a random letter I picked, but let's pretend I picked it to stand for kill)
double range; //range from you min and max
double c = 0; //this is your real random number that will be used to return
range = (b - a) + 1;
if (rand() == 138) srand(rand() + clock());
//1 in 32k odds to reseed the RNG uses both a rand number and the clock (clock isn't seconds, it's system ticks, faster than seconds)
if ((rand() + clock()) % 5 == 1)
//basicly 1 in 5 chance of looping a wasting some random numbers
{
for (k = ((clock() % 4) + ((rand() + clock()) % 7) + (rand() % 18) + 9); k > 0; k--)//comes up with a number to loop from about 9 to 35 times
{
rand(); //wastes some random numbers
}
}
c = a + int(range * rand() / (RAND_MAX + 1));
return c;
}
int main(int argc, char *argv[])
{
time_t sseconds; //should seed the random number generator
time_t cseconds;
time_t tsec;
time(&sseconds);
srand((unsigned int) sseconds);
cout<<"\nTime - "<