ISO C Random
This algorithm generates a random number.
static int ISOCRandom(unsigned int seed) {
unsigned int next = seed;
int result;
next *= 1103515245;
next += 12345;
result = (int)((unsigned int)(next / 65536) % 2048);
next *= 1103515245;
next += 12345;
result <<= 10;
result ^= (int)((unsigned int)(next / 65536) % 1024);
next *= 1103515245;
next += 12345;
result <<= 10;
result ^= (int)((unsigned int)(next / 65536) % 1024);
seed = next;
return result;
}
Example
int value = ISOCRandom(568);
Output
2145552894