title | description | ms.date | api_name | api_location | api_type | topic_type | f1_keywords | helpviewer_keywords | ms.assetid | |||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
scalbn, scalbnf, scalbnl, scalbln, scalblnf, scalblnl |
API reference for scalbn, scalbnf, scalbnl, scalbln, scalblnf, and scalblnl; which multiplies a floating-point number by an integral power of `FLT_RADIX`. |
9/1/2020 |
|
|
|
|
|
|
df2f1543-8e39-4af4-a5cf-29307e64807d |
Multiplies a floating-point number by an integral power of FLT_RADIX
.
double scalbn(
double x,
int exp
);
float scalbn(
float x,
int exp
); // C++ only
long double scalbn(
long double x,
int exp
); // C++ only
float scalbnf(
float x,
int exp
);
long double scalbnl(
long double x,
int exp
);
#define scalbn(X, INT) // Requires C11 or higher
double scalbln(
double x,
long exp
);
float scalblnf(
float x,
long exp
);
long double scalblnl(
long double x,
long exp
);
#define scalbln(X, LONG) // Requires C11 or higher
float scalbln(
float x,
long exp
); // C++ only
long double scalbln(
long double x,
long exp
); // C++ only
x
Floating-point value.
exp
Integer exponent.
The scalbn
functions return the value of x
* FLT_RADIX
exp when successful. On overflow (depending on the sign of x
), scalbn
returns +/- HUGE_VAL
; the errno
value is set to ERANGE
.
For more information about errno
and possible error return values, see errno
, _doserrno
, _sys_errlist
, and _sys_nerr
.
FLT_RADIX
is defined in <float.h> as the native floating-point radix; on binary systems, it has a value of 2, and scalbn
is equivalent to ldexp
.
Because C++ allows overloading, you can call scalbn
and scalbln
overloads that take and return float
or long double
types. In a C program, unless you're using the <tgmath.h> macro to call this function, scalbn
always takes a double
and an int
and returns a double
, and scalbln
always takes a double
and a long
and returns a double
.
If you use the <tgmath.h> scalbn()
or scalbln
macros, the type of the argument determines which version of the function is selected. See Type-generic math for details.
By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.
Function | C header | C++ header |
---|---|---|
scalbn , scalbnf , scalbnl , scalbln , scalblnf , scalblnl |
<math.h> | <cmath> |
scalbn or scalbln macro |
<tgmath.h> |
For more compatibility information, see Compatibility.
// crt_scalbn.c
// Compile using: cl /W4 crt_scalbn.c
#include <math.h>
#include <stdio.h>
int main( void )
{
double x = 6.4, y;
int p = 3;
y = scalbn( x, p );
printf( "%2.1f times FLT_RADIX to the power of %d is %2.1f\n", x, p, y );
}
6.4 times FLT_RADIX to the power of 3 is 51.2
Math and floating-point support
frexp
ldexp
modf
, modff
, modfl