Module: Random::Formatter

Included in:
Random
Defined in:
random.c

Instance Method Summary collapse

Instance Method Details

#random_numberFloat #random_number(max) ⇒ Numeric #randFloat #rand(max) ⇒ Numeric

Generates formatted random number from raw random bytes. See Random#rand.

Overloads:


1298
1299
1300
1301
1302
1303
1304
1305
1306
# File 'random.c', line 1298

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;
}

#random_numberFloat #random_number(max) ⇒ Numeric #randFloat #rand(max) ⇒ Numeric

Generates formatted random number from raw random bytes. See Random#rand.

Overloads:


1298
1299
1300
1301
1302
1303
1304
1305
1306
# File 'random.c', line 1298

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;
}