I want to generate random numbers using Xor shift. I tried this example from wikipedia but it's generating random numbers like 332584831 1855942593 -276217806 913087829 486807926
I would like random number between 0 and the max of int.
here is the sample of code which I am using :
int random_state =1234;
int randomNumber()
{
int result = random_state;
result ^= result << 13;
result ^= result >> 17;
result ^= result << 5;
random_state = result;
return result;
}
Aucun commentaire:
Enregistrer un commentaire