frexp, frexpl
raw OCR
Splits a number into mantissa and exponent.
Defined in header <math.h>
Syntax
#include <math.h>
double frexp(double x, int *exponent);
long double frexpKlong double x, int *exponent);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| frexp | ■ | ■ | ■ | ■ | |
| frexpl | ■ | ■ |
Remarks
frexp calculates the mantissa m (a double greater than or equal to 0.5 and less than 1) and the integer value n, such that x (the original double value) equals m x 2". frexp stores n in the integer that exponent points to. frexpl is the long double version; it takes a long double argument for x and returns a long double result.
Return value
frexp and frexpl return the mantissa m.
Error handling for these routines can be modified through the functions mattierr and _matherrl.
See also
Example
#include <math.h>
#include <stdio.h>
int main(void)
{
double mantissa, number = 8.0;
int exponent;
mantissa = frexp(number, *exponent);
printfC'The number %lf is %lf times two to the power of %d\n", number,
mantissa, exponent);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/math.h/frexp/
· short form /3.1/frexp/