Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Gets the mantissa and exponent of a floating-point number.

double frexp(
   double x,
   int *expptr 
float frexp(
   float x,
   int * expptr
);  // C++ only
long double frexp(
   long double x,
   int * expptr
);  // C++ only



Floating-point value.


Pointer to stored integer exponent.

frexp returns the mantissa. If x is 0, the function returns 0 for both the mantissa and the exponent. If expptr is NULL, the invalid parameter handler is invoked as described in Parameter Validation. If execution is allowed to continue, this function sets errno to EINVAL and returns 0.

The frexp function breaks 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.

C++ allows overloading, so you can call overloads of frexp. In a C program, frexp always takes a double and an integer and returns a double.

Function Required header Compatibility



ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For additional compatibility information, see Compatibility in the Introduction.

// crt_frexp.c
// This program calculates frexp( 16.4, &n )
// then displays y and n.

#include <math.h>
#include <stdio.h>

int 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

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

© 2015 Microsoft