HP C/iX Library Reference Manual (30026-90004)
Chapter 5 229
HP C/iX Library Function Descriptions
ldexp
ldexp
Accepts a double
value
and an integer exponent
exp,
and returns a double quantity
equal to
value
* 2
exp
.
Syntax
#include <math.h>
double ldexp (double
value
, int
exp
);
Parameters
value
A real number that is to be multiplied by 2
exp
.
exp
The integer exponent value to which 2 is raised.
Return Values
n The result of
value
* 2
exp
.
0 An underflow condition has occurred; errno is set to indicate the error.
HUGE_VAL An overflow condition has occurred.
Description
The ldexp function multiplies the floating-point argument
value
by an integral power of
2
exp
.
Example
The following program accepts two number arguments,
value
and
exp,
and outputs the
result:
main(argc, argv)
int argc;
char *argv[ ];
{
double value, result, ldexp();
int exp;
result = ldexp(value, exp);
printf("%g * 2^%d = %g\n", value, exp, result);
}
See Also
ANSI C 4.5.4.3, POSIX.1 8.1