I am in need of a "debiased" clamp function, to generate a uniformly-distributed random number from a good PRNG. Let's assume that `RNG` in the below code is a field containing an instance of a good (or good enough) PRNG such as PCG, Xoshiro, or MT, which produced a reasonably-uniform distribution of random integers. ```csharp public int GetClamped(int maxnum) { // maxnum is totally arbitrary here, and likely not a power of 2 int cap = int.MaxValue / maxnum * maxnum; int r; do { r = RNG.NextPositiveInt(); // Returns a value in the range [0, int.MaxValue] } while (r >= cap); return r >= maxnum ? r % maxnum : r; } ``` I wonder if this can be optimized further, seeing I have 2 divisions and a multiplication there.