scalb
计算x * 2^y的值。
接口定义
C interface:
float scalbf(float x, float y);
double scalb(double x, double y);
long double scalb(long double x, long double y);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 输入x为nan,输入y为任意值,返回x*y。
- 输入y为nan或+∞,输入x为任意值,返回x*y。
- 输入x为±0,y为-∞,返回x。
- 输入y为-∞,x非0,返回±0(符号与x相同)。
- 输入y为非整数,输入x为任意值,返回nan。
依赖
C: "km.h"
示例
C interface:
// typical usage double x1 = 0.0, x2 = -0.0, x3 = 2.0, x4 = 1100.0; double y1 = -0.0, y2 = 0.0, y3 = 3.0, y4 = 2.1; // special handing double a = INFINITY, b = -INFINITY, c = NAN; printf("scalb(0.0, -0.0) = %.15f\n", scalb(x1, y1)); printf("scalb(-0.0, 0.0) = %.15f\n", scalb(x2, y2)); printf("scalb(2.0, 3.0) = %.15f\n", scalb(x3, y3)); printf("scalb(2.0, 2.1) = %.15f\n", scalb(x3, y4)); printf("scalb(0.0, -INFINITY) = %.15f\n", scalb(x1, b)); printf("scalb(-0.0, -INFINITY) = %.15f\n", scalb(y1, b)); printf("scalb(2.0, -INFINITY) = %.15f\n", scalb(x3, b)); printf("scalb(2.0, 1100.0) = %.15f\n", scalb(x3, x4)); printf("scalb(INFINITY, 2.0) = %.15f\n", scalb(a, x2)); printf("scalb(-INFINITY, 2.0) = %.15f\n", scalb(b, x2)); printf("scalb(NAN, 2.0) = %.15f\n", scalb(c, x3)); printf("scalb(NAN, INFINITY) = %.15f\n", scalb(c, a)); printf("scalb(NAN, -INFINITY) = %.15f\n", scalb(c, b)); printf("scalb(INFINITY, -INFINITY) = %.15f\n", scalb(a, b)); /* * scalb(0.0, -0.0) = 0.000000000000000 * scalb(-0.0, 0.0) = -0.000000000000000 * scalb(2.0, 3.0) = 16.000000000000000 * scalb(2.0, 2.1) = nan * scalb(0.0, -INFINITY) = 0.000000000000000 * scalb(-0.0, -INFINITY) = -0.000000000000000 * scalb(2.0, -INFINITY) = 0.000000000000000 * scalb(2.0, 1100.0) = inf * scalb(INFINITY, 2.0) = inf * scalb(-INFINITY, 2.0) = -inf * scalb(NAN, 2.0) = nan * scalb(NAN, INFINITY) = nan * scalb(NAN, -INFINITY) = nan * scalb(INFINITY, -INFINITY) = nan * * */
父主题: 指数和对数函数