Random

Random number generation.

public let blob : shared () -> async Blob

public func new(seed : Blob) : Random

Opinionated choice of PRNG from a given seed.

public func newAsync() : AsyncRandom

Uses entropy from the management canister with automatic resupply.

class Random(generator : () -> Blob)

public func bool() : Bool

Random choice between true and false.

public func byte() : Nat8

Random Nat8 value in the range [0, 256).

public func float() : Float

Random Float value in the range [0, 1). The resolution is maximal (i.e. all relevant mantissa bits are randomized).

public func intRange(min : Int, maxExclusive : Int) : Int

public func natRange(min : Nat, maxExclusive : Nat) : Nat

class AsyncRandom(generator : () -> async* Blob)

public func bool() : async* Bool

public func byte() : async* Nat8

public func float() : async* Float

public func natRange(min : Nat, maxExclusive : Nat) : async* Nat

public func intRange(min : Int, maxExclusive : Int) : async* Int