So, I've tried to change macro to
Code:
#define randint0(M) ((s32b) Rand_div(M+1))
Angband developers must used it correctly, despite wrong description.
Kudos!
#define randint0(M) ((s32b) Rand_div(M+1))
. AFAICT it should work for unbiased uniform randomness. /* Partition size */ n = (0x10000000 / m);
#define RAND_MAX=0xFFFFFFFF;
while(1)
{
r = WELLRNG1024a();
if (r < RAND_MAX - RAND_MAX % m)
return r % m;
}
Also, it's always nice to see another "old" dev return. Welcome back!
/* Partition size */
n = (0x10000000 / m);
...
while (1) {
/* Get the next pseudorandom number */
r = WELLRNG1024a();
/* Mutate a 28-bit "random" number */
r = ((r >> 4) & 0x0FFFFFFF) / n;
/* Done */
if (r < m) break;
}
}
Leave a comment: