RAD Studio
ContentsIndex
PreviousUpNext
frexp, frexpl

Header File 

math.h  

Category 

Math Routines 

Prototype 

double frexp(double x, int *exponent); 

long double frexpl(long double x, int *exponent); 

Description 

Splits a number into mantissa and exponent. 

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 * 2n. 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 _matherr and _matherrl. 

Example  

#include <math.h>
#include <stdio.h>
int main(void)
{
   double mantissa, number;
   int exponent;
   number = 8.0;
   mantissa = frexp(number, &exponent);
   printf("The number %lf is ", number);
   printf("%lf times two to the ", mantissa);
   printf("power of %d\n", exponent);
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
frexp 
frexpl 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!