scalbn
Compute the result of x * 2^y.
Interface Definition
C interface:
float scalbnf(float x, int y);
double scalbn(double x, int y);
long double scalbnl(long double x, int y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Integer value of the input data |
Input |
Return Value
- The result of x * 2^y is returned. If an overflow occurs, +∞ or -∞ is returned (the sign is the same as that of x).
Dependencies
C: "km_l9.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // typical usage double x1 = 0.0, x2 = -0.0, x3 = 2.0; long int y1 = 2, y2 = 3, y3 = 4, y4 = 5, y5 = 1100; // special handling double a = INFINITY, b = -INFINITY, c = NAN; printf("scalbn(0.0, 2) = %.15f\n", scalbn(x1, y1)); printf("scalbn(-0.0, 3) = %.15f\n", scalbn(x2, y2)); printf("scalbn(2.0, 4) = %.15f\n", scalbn(x3, y3)); printf("scalbn(2.0, 5) = %.15f\n", scalbn(x3, y4)); printf("scalbn(2.0, 1100) = %.15f\n", scalbn(x3, y5)); printf("scalbn(INFINITY, 2) = %.15f\n", scalbn(a, y1)); printf("scalbn(-INFINITY, 2) = %.15f\n", scalbn(b, y1)); printf("scalbn(NAN, 2) = %.15f\n", scalbn(c, y1)); /* * scalbn(0.0, 2) = 0.000000000000000 * scalbn(-0.0, 3) = -0.000000000000000 * scalbn(2.0, 4) = 32.000000000000000 * scalbn(2.0, 5) = 64.000000000000000 * scalbn(2.0, 1100) = inf * scalbn(INFINITY, 2) = inf * scalbn(-INFINITY, 2) = -inf * scalbn(NAN, 2) = nan */ |
Parent topic: Exponential and Logarithmic Functions