Method: Math#frexp

Defined in:
math.c

#frexp(x) ⇒ Array (private)

Returns a two-element array containing the normalized fraction (a Float) and exponent (a Fixnum) of x.

fraction, exponent = Math.frexp(1234)   #=> [0.6025390625, 11]
fraction * 2**exponent                  #=> 1234.0

Returns:



689
690
691
692
693
694
695
696
697
698
699
# File 'math.c', line 689

static VALUE
math_frexp(VALUE obj, VALUE x)
{
    double d;
    int exp;

    Need_Float(x);

    d = frexp(RFLOAT_VALUE(x), &exp);
    return rb_assoc_new(DBL2NUM(d), INT2NUM(exp));
}