The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017



The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at ldexp.

Multiplies a floating-point number by an integral power of two.

double ldexp(  
   double x,  
   int exp   
float ldexp(  
   float x,  
   int exp  
);  // C++ only  
long double ldexp(  
   long double x,  
   int exp  
);  // C++ only   
float ldexpf(  
   float x,  
   int exp  
long double ldexpl(  
   long double x,  
   int exp  


Floating-point value.

Integer exponent.

The ldexp function returns the value of x * 2exp if successful. On overflow, and depending on the sign of x, ldexp returns +/– HUGE_VAL; the errno value is set to ERANGE.

For more information about errno and possible error return values, see errno, _doserrno, _sys_errlist, and _sys_nerr.

Because C++ allows overloading, you can call overloads of ldexp that take float or long double types. In a C program, ldexp always takes a double and an int and returns a double.

RoutineC headerC++ header
ldexp, ldexpf, ldexpl<math.h><cmath>

For compatibility information, see Compatibility.

// crt_ldexp.c  
#include <math.h>  
#include <stdio.h>  
int main( void )  
   double x = 4.0, y;  
   int p = 3;  
   y = ldexp( x, p );  
   printf( "%2.1f times two to the power of %d is %2.1f\n", x, p, y );  

4.0 times two to the power of 3 is 32.0  


Floating-Point Support
modf, modff, modfl