frexp(3C)
_________________________________________________________________
frexp function
Return the mantissa of a number of type double.
_________________________________________________________________
Calling Sequence
#include <math.h>
double frexp(), value, result;
int *exptr;
result = frexp(value, exptr);
where result is the mantissa of the value. It has the
same sign as the value, and the absolute value of
the result is greater than or equal to 0.5 and less
than 1.0.
value is the double precision number you want to
split into the mantissa and exponent parts.
exptr is an integer pointer, into which the exponent
of the number (base 2) is stored.
Description
You can write any nonzero number as x * 2**n, where the mantissa
(x) is in the range 0.5 <= |x| < 1, and the exponent (n) is an
integer. On this basis, the frexp function returns the mantissa
of value, and stores the exponent in a location that exptr points
to.
Returns
The frexp function returns the mantissa (x) of the value you
pass, based on the assumption that the value is represented as x
* 2**n.
Related Functions
See also the exp, ldexp, and pow functions.
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
frexp(3C)
Example
/* Program test for the frexp() function */
#include <stdio.h>
#include <math.h>
double frexp(), number, result, atof();
int i, exp;
main(argc, argv)
int argc;
char *argv[];
{
for (i = 1; i < argc; i++) {
number = atof(argv[i]);
result = frexp(number, &exp);
printf("Number %g has an exponent ", number);
printf("of %d, mantissa of %g\n", exp, result);
}
}
For the input values of 0.0031416, 3.1416, and 3141.6, the
program produces the following results:
Number 0.0031416 has an exponent of -8, mantissa of 0.80425
Number 3.1416 has an exponent of 2, mantissa of 0.7854
Number 3141.6 has an exponent of 12, mantissa of 0.766992
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)