function
<cmath> <ctgmath>
scalbndouble scalbn (double x , int n); float scalbnf (float x , int n);long double scalbnl (long double x, int n);
double scalbn (double x , int n); float scalbn (float x , int n);long double scalbn (long double x, int n); double scalbn (T x , int n); // additional overloads for integral types
Scale significand using floating-point base exponent
Scales x by FLT_RADIX raised to the power of n, returning the same as: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.
On most platforms, FLT_RADIX is 2
, making this function equivalent to ldexp.
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).
long int
as second argument.
If a range error occurs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* scalbn example */
#include <stdio.h> /* printf */
#include <float.h> /* FLT_RADIX */
#include <math.h> /* scalbn */
int main ()
{
double param, result;
int n;
param = 1.50;
n = 4;
result = scalbn (param , n);
printf ("%f * %d^%d = %f\n", param, FLT_RADIX, n, result);
return 0;
}
1.500000 * 2^4 = 24.000000
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