Compute a real number from the mantissa and exponent.
#include <math.h>
double ldexp( double x, int exp );
long double _ldexpl( long double x, int exp );
x | Floating-point value | |
exp | Integer exponent |
The ldexp and _ldexpl functions calculate the value of x * 2exp.
The ldexp and _ldexpl functions return x * 2exp. If an overflow results, the functions return ±HUGE_VAL (depending on the sign of x) and set errno to ERANGE.
The _ldexpl function uses the 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.
ldexp
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
_ldexpl
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* LDEXP.C */
#include <math.h>
#include <stdio.h>
void 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