Get the mantissa and exponent of a floating-point number.
#include <math.h>
double frexp( double x, int *expptr );
long double _frexpl( long double x, int *expptr );
x | Floating-point value | |
expptr | Pointer to stored integer exponent |
The frexp and _frexpl functions break down the floating-point value (x) into a mantissa (m) and an exponent (n), such that the absolute value of m is greater than or equal to 0.5 and less than 1.0, and x = m*2n. The integer exponent n is stored at the location pointed to by expptr.
The _frexpl function is the 80-bit counterpart and uses an 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.
These functions return the mantissa. If x is 0, the function returns 0 for both the mantissa and the exponent. There is no error return.
frexp
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
_frexpl
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* FREXP.C: This program calculates frexp( 16.4, &n ), then displays y
* and n.
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double x, y;
int n;
x = 16.4;
y = frexp( x, &n );
printf( "frexp( %f, &n ) = %f, n = %d\n", x, y, n );
}
frexp( 16.400000, &n ) = 0.512500, n = 5