<bo*@coolgroups.com> wrote:
what algorithm does the rand function use?
As mentioned elsewhere, whatever the deigner chooses to use.
The link below suggests:
static unsigned long int next = 1;
int rand(void) // RAND_MAX assumed to be 32767
{
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % 32768;
}
is at least acceptable. If one wanted a quick and dirty generator with
uniform results across different platforms, one might use that. Calling
rand() will likely give different results with different compilers. I
recall seeing that 12345 in a snippet elsewhere on the net, too.
http://cer.freeshell.org/renma/