Blockchain Commons Rand TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Function rngNextWithUpperBound

    • Returns a random value that is less than the given upper bound.

      Uses Lemire's "nearly divisionless" method for generating random integers in an interval. For a detailed explanation, see: https://arxiv.org/abs/1805.10941

      Parameters

      • rng: RandomNumberGenerator

        The random number generator to use

      • upperBound: bigint

        The upper bound for the randomly generated value. Must be non-zero.

      Returns bigint

      A random value in the range [0, upperBound). Every value in the range is equally likely.