function
<cmath> <ctgmath>
scalbln
double scalbln (double x , long int n); float scalblnf (float x , long int n);long double scalblnl (long double x, long int n);
double scalbln (double x , long int n); float scalbln (float x , long int n);long double scalbln (long double x, long int n); double scalbln (T x , long int n); // additional overloads for integral types
Scale significand using floating-point base exponent (long)
Scales x by FLT_RADIX raised to the power of n, returning the result of computing:
scalbn(x,n)
= x * FLT_RADIXn
Presumably, x and n are the components of a floating-point number in the system; In such a case, this function may be optimized to be more efficient than the theoretical operations to compute the value explicitly.
There also exists another version of this function: scalbn, which is identical, except that it takes an int
as second argument.
Header
<tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (
<cmath>
) for the
integral types: These overloads effectively cast
x to a
double
before calculations (defined for
T being any
integral type).
Parameters
- Value representing the significand.</dd>
- exp
- Value of the exponent.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
/* scalbln example */
#include <stdio.h> /* printf */
#include <float.h> /* FLT_RADIX */
#include <math.h> /* scalbn */
int main ()
{
double param, result;
long n;
param = 1.50;
n = 4L;
result = scalbln (param , n);
printf ("%f * %d^%d = %f\n", param, FLT_RADIX, n, result);
return 0;
}
|
Output:
1.500000 * 2^4 = 24.000000
|
See also
- scalbn
- Scale significand using floating-point base exponent (function)
- ldexp
- Generate value from significand and exponent (function)
- logb
- Compute floating-point base logarithm (function)