C Math scalbln() Function
Example
Multiply numbers by a power of 2:
printf("%f\n", scalbln(2.5, 2));
printf("%f", scalbln(10.0, -3));
Definition and Usage
The scalbln() function returns x multiplied by FLT_RADIX to the power of y. FLT_RADIX is the base that the computer uses to store decimal numbers. It is 2 on almost all computers.
It works like scalbn(), but y is a long instead of an int. In the example, scalbln(2.5, 2) is 2.5 * 2 * 2, which is 10.
The scalbln() function is defined in the <math.h> header file.
Syntax
double scalbln(double x, long y);
There are also versions for float and long double values: scalblnf() and scalblnl().
Parameter Values
| Parameter | Description |
|---|---|
| x | Required. The number to multiply. |
| y | Required. A long with the power to use. A negative value divides instead. |
Technical Details
| Returns: | A double value with the result. |
|---|
Related Pages
Read more about math in our C Math Tutorial.