Method: Math#frexp
- Defined in:
- math.c
#frexp(x) ⇒ Array (private)
Returns a 2-element array containing the normalized signed float fraction and integer exponent of x such that:
x = fraction * 2**exponent
See IEEE 754 double-precision binary floating-point format: binary64.
-
Domain:
[-INFINITY, INFINITY]. -
Range
[-INFINITY, INFINITY].
Examples:
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).
782 783 784 785 786 787 788 789 790 |
# File 'math.c', line 782 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)); } |