break a floating-point number into a normalized fraction and an integral power of 2
#include <math.h> double frexp( double value, int *exp );
The frexp() function breaks a floating-point number into a normalized fraction and an integral power of 2. It stores the integral power of 2 in the int object pointed to by exp.
The value of x, such that x is a double with magnitude in the interval [0.5, 1) or 0, and value equals x times 2 raised to the power *exp. If value is 0, then both parts of the result are 0.
#include <stdio.h>
#include <math.h>
void main()
{
int expon;
double value;
value = frexp( 4.25, &expon );
printf( "%f %d\n", value, expon );
value = frexp( -4.25, &expon );
printf( "%f %d\n", value, expon );
}
produces the output
0.531250 3 -0.531250 3
ANSI
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |