The only thing that's changed between 3.2.3 and 3.5.1 (just picked 3.2.3 at random, no pun intended) is the randomize function used to use the microseconds since program start, but now uses that and system time combined. Otherwise the actual random function code is unchanged: it's PCG32.
Assuming a random number generator is evenly distributed (PCG32 is supposed to be pretty good, so I'll assume it is), the modulo method of getting a smaller range will only be evenly distributed if it's a factor of the total range. Otherwise lower numbers will have a slight higher chance.
For example, let's say randi() returned a number from 0-11 and we want to get a random from 0-9.
0 % 10 = 0
1 % 10 = 1
2 % 10 = 2
3 % 10 = 3
4 % 10 = 4
5 % 10 = 5
6 % 10 = 6
7 % 10 = 7
8 % 10 = 8
9 % 10 = 9
10 % 10 = 0
11 % 10 = 1
Because it didn't neatly fit, we have a couple of values that got repeated. So getting a 0 or a 1 each have a chance of 2/12, while other values have 1/12 chance.
(randi() actually has a range of 0-4,294,967,295)
If I do Dave's code with a modulus of 10, the counts are:
99529, 99580, 99840, 99838, 100370, 100154, 99828, 100328, 100489, 100044
That's pretty even.
But if I modify it to force randi() to be a 0-11 range (I rejected any value over 11 from the count) we get this:
31328, 31192, 15538, 15655, 15431, 15581, 15548, 15731, 15565, 15747
There it's clear that results of 0 or 1 are far more likely.
The reason it's not visible in the first one is that the bigger the range of values, the less the effect is.
I made a test in C++, the actual distribution of %10 values from a range of 0-4,294,967,295 is (this isn't using a random, just how the modulus is distributed):
Values 0 - 5 occur 429,496,730 times.
Values 6 - 9 occur 429,496,729 times.
It's still slightly weighted towards the low half, but only by a microscopic amount. Plus the RNG might not have perfect distribution anyway.
So if you aren't doing something critical like poker machines, the difference shouldn't really matter in general game dev. 🙂
One case where it's going to be more noticeable is the old C/C++ rand() function. It returns a range of only 0-32767. Plus it just sucks as an algorithm overall.
Sorry, been away from teaching for half a year, got to keep in shape. 🙂