 <p>Let's say RAND_MAX is 150. (Obviously it's not actually.) And we want numbers from 0-99. Then we do <code>rand() % 100</code>. Cool.</p> <p>The problem is, what if RAND() returns a number greater than 100? Let's take 102. <code>102 % 100 = 2</code>, and <code>2 % 100 = 2</code>. So there is a <code>2/150</code> chance that we will get a 2 with the given algorithm. But a number above 50? There's only a <code>1/150</code> chance that we'll get it. The higher RAND_MAX, the less of a problem this is, but it remains an issue. </p> <p>Notice that if RAND_MAX were divisible by the number that you wanted to "modulate" it by, all numbers would be equally likely. i.e if RAND_MAX were 200 rather than 150. Hope this helps!</p> <p>Edit: the actual math.</p> <p>RAND_MAX is guaranteed to be at least 32767. If we want a range from 0-99, we can do <code>RAND() % 100</code>. Then, numbers between 0 and 67 will all appear 328 possible times, while 68-99 will appear only 327 times each. That's a 1.0010071% chance for the first 68 numbers, and only a 0.9979553% chance for the rest of them. We want them all to be 1%! Usually not a major issue, but depending on the use case, could show some strange behavior.</p>