Microsoft.Scripting.Utils.MathUtils.Random C# (CSharp) Method

Random() public static method

public static Random ( this generator, BigInteger limit ) : BigInteger
generator this
limit Microsoft.Scripting.Math.BigInteger
return Microsoft.Scripting.Math.BigInteger
        public static BigInteger Random(this Random generator, BigInteger limit) {
            ContractUtils.Requires(limit.Sign > 0, "limit");
            ContractUtils.RequiresNotNull(generator, "generator");

            // TODO: this doesn't yield a uniform distribution (small numbers will be picked more frequently):
            uint[] result = new uint[limit.GetWordCount() + 1];
            for (int i = 0; i < result.Length; i++) {
                result[i] = unchecked((uint)generator.Next());
            }
            return new BigInteger(1, result) % limit;
        }
#else

Same methods

MathUtils::Random ( this generator, System.Numerics.BigInteger limit ) : System.Numerics.BigInteger