Guardian C Library Calls Reference Manual

Reference to Library Calls
Guardian TNS C Library Calls Reference Manual128833 3-103
ldexp
ldexp
The ldexp function multiplies a floating-point number by an integral power of 2.
expr1
is an expression of type double.
expr2
is an expression of type int.
Return Value
is the value expr1*2expr2. If an overflow occurs, ldexp returns the value
HUGE_VAL. If an underflow occurs, it returns the value zero. In either of these
cases, ldexp sets errno to ERANGE (a range error).
Example
This example prints “The result is 4.920000.”:
#include <mathh>
#include <stdioh>
int main(void)
{
double r, x;
int i;
x = 1.23;
i = 2;
r = ldexp(x, i);
printf("The result is %f.", r);
}
#include <mathh>
double ldexp(double expr1, int expr2);