.TH frexp() "" "" "General Function (libc)"
.PC "Separate fraction and exponent"
.B "#include <math.h>"
\fBdouble frexp(\fIreal\^\fB, \fIep\^\fB)\fR
\fBdouble \fIreal\^\fB; int *\fIep\^\fB;\fR
.PP
.B frexp()
breaks double-precision floating point numbers into fraction and
exponent.
It returns the fraction
.I m
of its
.I real
argument, such that 0.5 <= \fIm\fR < 1 or \fIm\fR=0,
and stores the binary exponent
.I e
in the location pointed to by
.IR ep .
These numbers satisfy the equation
\fIreal\fR = \fIm\fR * 2\*^\fIe\fR.
.SH Example
This example prompts for a number, then uses
.B frexp()
to break it into its fraction and exponent.
.DM
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
.DE
.DM
main()
{
	double real, fraction;
	int ep;
.DE
.DM
	char string[64];
.DE
.DM
	for (;;) {
		printf("Enter number: ");
		if (gets(string) == NULL)
			break;
.DE
.DM		real = atof(string);
		fraction = frexp(real, &ep);
		printf("%lf is the fraction of %lf\en",
			fraction, real);
		printf("%d is the binary exponent of %lf\en",
			ep, real);
	}
}
.DE
.SH "See Also"
.Xr "atof()," atof
.Xr "ceil()," ceil
.Xr "fabs()," fabs
.Xr "floor()," floor
.Xr "ldexp()," ldexp
.Xr "libc," libc
.Xr "modf()" modf
.br
\*(AS, \(sc7.5.4.3
.br
\*(PX Standard, \(sc8.1
