Uniformity of random numbers taken modulo N

You are correct, rand() % N is not precisely uniformly distributed. Precisely how much that matters depends on the range of numbers you want and the degree of randomness you want, but if you want enough randomness that you’d even care about it you don’t want to use rand() anyway. Get a real random number … Read more