In C, scalbln() returns x × FLT_RADIXn. On binary systems, FLT_RADIX is 2, so this is like scaling by a power of two with a long exponent.
You pass a double and a long power. Both are required. The result is a double. Include <math.h>. Prefer this over a naive pow loop when you only need radix scaling.
Use scalbn() when the exponent fits in an int. Use scalbln when you need the wider long range for n.
Syntax
Pass the value, then the long exponent. Start with this call.
C
scalbln(1.5, 3L);
Call
What it does
scalbln(1.5, 3L);
Returns 12 on binary platforms (1.5 × 2³).
Include <math.h>. On GCC, link with -lm. n is a long, not an int.
Library declarations
C
double scalbln(double x, long n);
float scalblnf(float x, long n);
long double scalblnl(long double x, long n);
Parameters
Parameter
Description
x
Required. The double to scale.
n
Required. The long power of FLT_RADIX. It can be negative.
Return Value
Return Value
Description
Scaled double
x multiplied by FLT_RADIX raised to n.
C Examples
Example 1 — Basic Radix Scale
Scale 1.5 by three powers of the radix (usually 2).
Portable thinking. Write for FLT_RADIX, not only for 2.
Example 3 — Use a Long Exponent
Show a call that needs the long parameter form.
C
#include <stdio.h>
#include <math.h>
int main(void) {
long n = 10L;
double x = 1.0;
double y = scalbln(x, n);
printf("2^10 scaled from 1 = %.1f\n", y);
return 0;
}
Output
2^10 scaled from 1 = 1024.0
How It Works
Store n as long. Matches the scalbln signature.
Start at 1. Simple mantissa.
Scale by 10. On binary hosts this is 1024.
Why long? Use this form when exponents may exceed int range.
Frequently Asked Questions
scalbln(x, n) returns x multiplied by FLT_RADIX to the power n, with n as a long.
x is the value to scale. n is the long exponent for FLT_RADIX. Both are required.
A double equal to x * FLT_RADIX^n (within floating-point limits).
Include <math.h>. On GCC, link with -lm.
Both scale by FLT_RADIX^n. scalbln takes a long exponent; scalbn takes an int exponent.