Module: Random::Formatter
Relationships & Source Files | |
Defined in: | random.c |
Overview
Generate a random number in the given range as ::Random
does
prng.random_number #=> 0.5816771641321361
prng.random_number(1000) #=> 485
prng.random_number(1..6) #=> 3
prng.rand #=> 0.5816771641321361
prng.rand(1000) #=> 485
prng.rand(1..6) #=> 3
Instance Method Summary
-
#random_number ⇒ Float
(also: #random_number)
Generates formatted random number from raw random bytes.
-
#random_number ⇒ Float
Alias for #rand.
Instance Method Details
#random_number ⇒ Float
#random_number(max) ⇒ Numeric
#random_number(range) ⇒ Numeric
#rand ⇒ Float
#rand(max) ⇒ Numeric
#rand(range) ⇒ Numeric
Also known as: #random_number
Generates formatted random number from raw random bytes. See Random#rand.
# File 'random.c', line 1589
static VALUE rand_random_number(int argc, VALUE *argv, VALUE obj) { rb_random_t *rnd = try_get_rnd(obj); VALUE v = rand_random(argc, argv, obj, rnd); if (NIL_P(v)) v = rand_random(0, 0, obj, rnd); else if (!v) invalid_argument(argv[0]); return v; }
Alias for #rand.