In C, scalbn() returns x × FLT_RADIXn. On binary platforms this is the same family of idea as multiplying by 2n, with n as an int.
You pass a double and an int power. Both are required. The result is a double. Include <math.h>. It is a clean way to change the exponent without calling a general power function.
Related helpers: ldexp(x, exp) multiplies by 2exp specifically, while scalbn uses FLT_RADIX. On binary hosts they often match.
Syntax
Pass the value, then the int exponent. Start with this call.
C
scalbn(1.5, 3);
Call
What it does
scalbn(1.5, 3);
Returns 12 on binary platforms (1.5 × 2³).
Include <math.h>. On GCC, link with -lm. n is an int.
Library declarations
C
double scalbn(double x, int n);
float scalbnf(float x, int n);
long double scalbnl(long double x, int n);
Parameters
Parameter
Description
x
Required. The double to scale.
n
Required. The int power of FLT_RADIX. It can be negative.