Multiply a floatingpoint number by an integral power of 2
Synopsis:
#include <math.h>
double ldexp( double x,
int exp );
float ldexp( float x,
int exp );
long double ldexpl( long double x,
int exp );
Arguments:
 x
 A floatingpoint number.
 exp
 The exponent of 2 to multiply x by.
Library:
libm
Use the l m option to
qcc
to link against this library.
Description:
These functions multiply the floatingpoint number
x by
2^{exp}.
A range error may occur.
To check for error situations, use
feclearexcept()
and
fetestexcept():
 Call feclearexcept(FE_ALL_EXCEPT) before calling
ldexp(), ldexpf(), or ldexpl().
 On return, if fetestexcept(FE_INVALID  FE_DIVBYZERO  FE_OVERFLOW  FE_UNDERFLOW)
is nonzero, then an error has occurred.
Returns:
x × 2^{exp}
For a correct value that would cause an underflow, these functions return 0.0.
 If these functions would cause an overflow, a range error occurs, and they return
±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL
(according to the sign of x), respectively.
 If the correct value would cause an underflow, range error may occur, and these functions return 0.0, or
(if IEC 60559 FloatingPoint isn't supported) an implementationdefined value no greater in magnitude than
DBL_MIN, FLT_MIN, and LDBL_MIN, respectively.
 If x is NaN, the functions return NaN.
 If x is ±0 or ±Inf, x is returned.
 If exp is 0, x is returned.
 If the correct value would cause an underflow, and is representable, a range error may occur,
and the correct value is returned.
Examples:
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#include <stdlib.h>
int main( void )
{
int except_flags;
double value;
feclearexcept(FE_ALL_EXCEPT);
value = ldexp( 4.7072345, 5 );
except_flags = fetestexcept(FE_INVALID  FE_DIVBYZERO  FE_OVERFLOW  FE_UNDERFLOW);
if(except_flags) {
/* An error occurred; handle it appropriately. */
}
printf( "%f\n", value );
return EXIT_SUCCESS;
}
produces the output:
150.631504
Classification:
ANSI,
POSIX 1003.1
Safety: 

Cancellation point 
No 
Interrupt handler 
No 
Signal handler 
No 
Thread 
Yes 