class method
Math.frexp
(::Math::double x) -> [ ::Float, ::Integer ]
Math.frexp(x) → [fraction, exponent]
math.c
View on GitHub ↗
static VALUE
math_frexp(VALUE unused_obj, VALUE x)
{
double d;
int exp;
d = frexp(Get_Double(x), &exp);
return rb_assoc_new(DBL2NUM(d), INT2NUM(exp));
}
Returns a 2-element array containing the normalized signed float fraction and integer exponent of x such that:
Example
x = fraction * 2**exponent
See IEEE 754 double-precision binary floating-point format: binary64.
-
Domain:
[-INFINITY, INFINITY]. -
Range[-INFINITY, INFINITY].
Examples:
Example
frexp(-INFINITY) # => [-Infinity, -1] frexp(-2.0) # => [-0.5, 2] frexp(-1.0) # => [-0.5, 1] frexp(0.0) # => [0.0, 0] frexp(1.0) # => [0.5, 1] frexp(2.0) # => [0.5, 2] frexp(INFINITY) # => [Infinity, -1]
Related: Math.ldexp (inverse of Math.frexp).