class · System
Random
public class System.Random : System.Any
Pseudo-random numbers. new Random(seed) gives the same numbers for the same seed; new Random() and
Random.Shared are seeded from the clock (and a counter, so two made at once differ). Not for secrets.
- Kind
- class
- Namespace
- System
- Assembly
- System.Core
- Access
- public
- Source file
Random.ant
Inheritance
- Base classes
-
AnyRandom
Constructors
constructor Random()
#
Seeded from the clock.
The same numbers for the same seed.
Properties
Methods
64 random bits.
From 0 up to (not including) Int32.MaxValue.
From 0 up to (not including) max (0 when max is 0).
From min up to (not including) max (min when they are equal).
From 0 up to (not including) Int64.MaxValue.
From 0 up to (not including) max.
From min up to (not including) max.
From 0 up to (not including) 1, in steps of 2^-53.
From 0 up to (not including) 1, in steps of 2^-24.
Fills buffer with random bytes.
method Shuffle<T>(items: T[]) -> void
#
Puts the elements in a random order (Fisher–Yates: every order as likely).
Private and internal members (10)
SplitMix64: spreads a seed over the four words of the state (never all zero).
Values below bound (> 0), all as likely: the high half of a 64-bit product (Lemire), retried in the rare
band that would favour some values.
Values below bound (> 0), all as likely: masked draws, retried when past the bound.
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
Random as Larva HIR, decompiled from its Larva HIR.
// Pseudo-random numbers. `new Random(seed)` gives the same numbers for the same seed; `new Random()` and
// `Random.Shared` are seeded from the clock (and a counter, so two made at once differ). Not for secrets.
public class System.Random : System.Any
{
field s0: u64
field s1: u64
field s2: u64
field s3: u64
static field made: u64
static field shared: System.Random?
// SplitMix64: spreads a seed over the four words of the state (never all zero).
method Seed(seed: u64) -> void
static method Mix(z: u64) -> u64
// Values below `bound` (> 0), all as likely: the high half of a 64-bit product (Lemire), retried in the rare
// band that would favour some values.
method Below(bound: u32) -> u32
// Values below `bound` (> 0), all as likely: masked draws, retried when past the bound.
method Below64(bound: u64) -> u64
// Seeded from the clock.
constructor Random()
// The same numbers for the same seed.
constructor Random(seed: i32)
// 64 random bits.
method NextUInt64() -> u64
// From 0 up to (not including) Int32.MaxValue.
method Next() -> i32
// From 0 up to (not including) `max` (0 when max is 0).
method Next(max: i32) -> i32
// From `min` up to (not including) `max` (min when they are equal).
method Next(min: i32, max: i32) -> i32
// From 0 up to (not including) Int64.MaxValue.
method NextInt64() -> i64
// From 0 up to (not including) `max`.
method NextInt64(max: i64) -> i64
// From `min` up to (not including) `max`.
method NextInt64(min: i64, max: i64) -> i64
// From 0 up to (not including) 1, in steps of 2^-53.
method NextDouble() -> f64
// From 0 up to (not including) 1, in steps of 2^-24.
method NextSingle() -> f32
// Fills `buffer` with random bytes.
method NextBytes(buffer: u8[]) -> void
// Puts the elements in a random order (Fisher–Yates: every order as likely).
method Shuffle<T>(items: T[]) -> void
// One shared generator (seeded from the clock).
static property Shared: System.Random
}