class

Ruby::V4::Random

Inherits Reference < Object

Constructors

global
Source
new(seed : Int)
Source

Class methods

rand(max) : Int64 | Float64
Source
rand
Source
srand(seed : Int) : Int
Source

Instance methods

bytes(n : Int) : Array(UInt8)

Случайные байты: слова genrand little-endian, хвост — младшие байты.

Source
limited(limit : UInt64) : UInt64

Целое в [0, limit] включительно (limited_rand из random.c Ruby).

Source
rand(max : Int) : Int64

Целое в [0, max) — rand(int) в Ruby.

Source
rand(range : Range(Int, Int))

rand(range): целые диапазоны включительно/исключительно.

Source
rand(range : Range(Float, Float)) : Float64

rand(float..float) / rand(int..float): как rand_range в random.c — random_real(excl) * (end-begin) + begin. Для inclusive-диапазона используется int_pair_to_real_inclusive из двух слов MT.

Source
rand(range : Range(Int, Float)) : Float64
Source
rand(max : Float) : Float64

rand(max : Float) — random_float * max.

Source
rand
Source