Re: Generating 2 independent random numbers
In article <d6b1612b-98bf-46bd-b70b-
02bb77592f1f@r66g2000hsg.googlegroups.com>, james.kanze@gmail.com
says...
[ ... ]
For example, consider the
following code:
#include <stdlib.h>
#include <iostream>
int main() {
srand(1);
int i;
for (i=0; i<9; i++)
std::cout << rand() << "\t";
std::cout << "\n";
for (; i<RAND_MAX; i++)
rand();
for (i=0; i<9; i++)
std::cout << rand() << "\t";
std::cout << "\n";
return 0;
}
According to your statements, the two lines should be
identical (with a possible offset).
If the period of the generator is RAND_MAX, the middle loop
should execute RAND_MAX-9, not RAND_MAX, for the two lines to
be the same.
Look at it again. The initialization part of the second loop is empty.
--
Later,
Jerry.
The universe is a figment of its own imagination.