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.
- Tipo
- class
- Espacio de nombres
- System
- Ensamblado
- System.Core
- Acceso
- public
- Archivo fuente
Random.ant
Herencia
- Clases base
-
AnyRandom
Constructores
constructor Random()
#
Seeded from the clock.
The same numbers for the same seed.
Propiedades
Métodos
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).
Miembros privados e internos (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.
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
Random en Larva HIR, descompilado a partir de su 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
}