I'm not sure about Mersenne Twister in particular, but what comes to mind is the typical advice that comes up when trying to get a random integer in the range [0, n). If you have PRNGs that return integers with a larger range than n, you should never use modulo to reduce the range, for example
x = rand() % n;
but you need to rescale the number
x = (int) floor(((double) rand()) / ((double) RAND_MAX)) * n);
instead of this. The reason is that the most significant pseudo-random number bits are usually more random than the low-order bits, therefore, while the modulo operation retains good floating-point results, it also discards these precious significant bits.
As long as I donβt know what the code you mentioned is done, it could be that masking the shift from right to left could be to reduce the range of random numbers in such a way as to discard the least significant bits.
source share