frexp()                  Get Mantissa and Exponent of Floating-Point Value
 
 #include   <math.h>
 
 double     frexp(x,expptr);
 double     x;                           Floating-point value
 int        *expptr;                     Pointer to stored integer exponent
 
 
    frexp() separates 'x' into a mantissa (m) and an exponent (n). The
    absolute value of (m) will be greater than or equal to 0.5 and less
    than 1.0: (n) will be the power of 2 exponent, and the following
    expression will be true:
 
                        ('x' == (m) * 2^(n))
 
    where ^ means "raised to the power of".  'expptr' is set to the
    exponent (n), and the mantissa (m) is returned.
 
    Returns:    The mantissa of 'x'.  If 'x' is 0.0, then '*expptr' is
                set to 0 and 0.0 is returned as the mantissa.
 
      Notes:    ldexp() performs the reverse function of frexp().
 
  -------------------------------- Example ---------------------------------
 
    The following statements calculate the mantissa and exponent for
    several floating-point values:
 
         #include <math.h>      /* Required for function definition only */
 
         main()
         {
             double a, b, c, d;
             int aexp, bexp, cexp, dexp;
 
             a = frexp(8.0, &aexp);     /* a =  0.5000, aexp =   4 */
             b = frexp(0.0, &bexp);     /* b =  0.0000, bexp =   0 */
             c = frexp(-32.5, &cexp);   /* c = -0.5078, cexp =   6 */
             d = frexp(1.0e-9, &dexp);  /* d =  0.5369, dexp = -29 */
         }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster