Hello everyone,I don't speak very good english , so sorry if i make any mistake
Can anyone explain me this code
[PHP]unsigned int rand_seed = 1;
void srand(unsigned int seed) {
rand_seed = seed;
}
int rand(void) { /*i don't understand what code do here down*/
return ((rand_seed = rand_seed * 1103515245 + 12345 ) >> 16) & 0x7fff;
}[/PHP]
I know that if we want to change the seed with time, we write [PHP]srand((int)time (NULL))[/PHP]
ps:If this thread is not in the right section please move it
Thanks in advance
Can anyone explain me this code
[PHP]unsigned int rand_seed = 1;
void srand(unsigned int seed) {
rand_seed = seed;
}
int rand(void) { /*i don't understand what code do here down*/
return ((rand_seed = rand_seed * 1103515245 + 12345 ) >> 16) & 0x7fff;
}[/PHP]
I know that if we want to change the seed with time, we write [PHP]srand((int)time (NULL))[/PHP]
ps:If this thread is not in the right section please move it
Thanks in advance
Comment