Module: Random::Formatter

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:



1478
1479
1480
1481
1482
1483
1484
1485
1486
# File 'random.c', line 1478

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:



1478
1479
1480
1481
1482
1483
1484
1485
1486
# File 'random.c', line 1478

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