Format
#include <math.h> double frexp(double x, int *expptr);
Language Level: ANSI
Threadsafe: Yes.
Description
The frexp() function breaks down the floating-point value x into a term m for the mantissa and another term n for the exponent. It is done such that x=m*2 n, and the absolute value of m is greater than or equal to 0.5 and less than 1.0 or equal to 0. The frexp() function stores the integer exponent n at the location to which expptr points.
Return Value
The frexp() function returns the mantissa term m. If x is 0, frexp() returns 0 for both the mantissa and exponent. The mantissa has the same sign as the argument x. The result of the frexp() function cannot have a range error.
Example that uses frexp()
This example separates the floating-point value of x, 16.4, into its mantissa 0.5125, and its exponent 5. It stores the mantissa in y and the exponent in n.
#include <math.h> #include <stdio.h> int main(void) { double x, m; int n; x = 16.4; m = frexp(x, n); printf("The mantissa is %lf and the exponent is %d\n", m, n); } /******************* Output should be similar to: *************** The mantissa is 0.512500 and the exponent is 5 */
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.