C++ cmath scalbln() Function
Example
Multiply numbers by a power of 2:
cout << scalbln(2.5, 2) << "\n";
cout << 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 <cmath> header file.
Syntax
scalbln(double x, long y)
The function also works with float and long double values. Then it returns a value of the same type.
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 Math Tutorial.