function
<cmath> <ctgmath>
ldexpdouble ldexp (double x, int exp);
double ldexp (double x , int exp); float ldexpf (float x , int exp);long double ldexpl (long double x, int exp);
double ldexp (double x , int exp); float ldexp (float x , int exp);long double ldexp (long double x, int exp);
double ldexp (double x , int exp); float ldexp (float x , int exp);long double ldexp (long double x, int exp); double ldexp (T x , int exp); // additional overloads for integral types
Generate value from significand and exponent
Returns the result of multiplying x (the significand) by2
raised to the power of exp (the exponent).
lexpr(x,exp)
= x * 2 exp
Header
<tgmath.h>provides a type-generic macro version of this function.
are provided in this header (
<cmath>
) for the
integral types: These overloads effectively cast
xto a
double
before calculations (defined for
Tbeing any
integral type).
x * 2 exp
If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range error occurs:
If an overflow
range erroroccurs, the global variable
errnois set to
ERANGE.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* ldexp example */
#include <stdio.h> /* printf */
#include <math.h> /* ldexp */
int main ()
{
double param, result;
int n;
param = 0.95;
n = 4;
result = ldexp (param , n);
printf ("%f * 2^%d = %f\n", param, n, result);
return 0;
}
0.950000 * 2^4 = 15.200000
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4