

frexp()                  General Function                 frexp()




Separate fraction and exponent

ddoouubbllee ffrreexxpp(_r_e_a_l, _e_p) ddoouubbllee _r_e_a_l; iinntt *_e_p;

frexp breaks  double-precision floating point  numbers into frac-
tion and  exponent.  It returns the fraction m  of its real argu-
ment, such  that 0.5 <= _m  < 1 or _m=0, and  stores the binary ex-
ponent e in the location pointed to by ep.  These numbers satisfy
the equation _r_e_a_l = _m * 2^_e.

***** Example *****

This example  prompts for a  number, then uses frexp  to break it
into its fraction and exponent.


#include <stdio.h>



main()
{
        extern char *gets();
        extern double frexp(), atof();
        double real, fraction;
        int ep;



        char string[64];



        for (;;) {
                printf("Enter number: ");
                if (gets(string) == NULL)
                        break;




                fraction = frexp(real, &ep);
                printf("%lf is the fraction of %lf\n",
                        fraction, real);
                printf("%d is the binary exponent of %lf\n",
                        ep, real);
        }









COHERENT Lexicon                                           Page 1




frexp()                  General Function                 frexp()



        putchar('\n');
}


***** See Also *****

atof(),  ceil(),  fabs(),  floor(), general  functions,  ldexp(),
modf()

















































COHERENT Lexicon                                           Page 2


