I'm trying (as a bungler noob) to use this alghoritm to generate random numbers
/* initialize state to random bits */
static unsigned long state[16];
/* init should also reset this to 0 */
static unsigned int index = 0;
/* return 32 bit random number */
unsigned long WELLRNG512(void)
{
unsigned long a, b, c, d;
a = state[index];
c = state[(index+13)&15];
b = a^c^(a<<16)^(c<<15);
c = state[(index+9)&15];
c ^= (c>>11);
a = state[index] = b^c;
d = a^((a<<5)&0xDA442D20UL);
index = (index + 15)&15;
a = state[index];
state[index] = a^b^d^(a<<2)^(b<<18)^(c<<28);
return state[index];
}
But it seems not to work (result every time 0). I found it here What is a good random number generator for a game? in the comments there is one that say "I waste one evening to understand why my code doesn't work: on 64 bit machines this code procude 64 bit number! Use sizeof(unsigned long) * 8
". I have a 64bit sistem but I don't understand what I have to do! It's surely better that I use stdlib.