Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


frexp()                  General Function                 frexp()




Separate fraction and exponent

double frexp(real, ep) double real; int *ep;

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 real = 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


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026