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

    Function rngNextWithUpperBoundU32

    • Returns a random 32-bit value that is less than the given upper bound. This matches Rust's behavior when called with u32 type.

      Uses Lemire's "nearly divisionless" method with 32-bit arithmetic.

      Parameters

      • rng: RandomNumberGenerator

        The random number generator to use

      • upperBound: number

        The upper bound for the randomly generated value. Must be non-zero and fit in u32.

      Returns number

      A random u32 value in the range [0, upperBound).