计算x的y次幂。
C interface:
float powf(float x, float y);
double pow(double x, double y);
Fortran interface:
RES = POWF(X, Y);
RES = POW(X, Y);
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
C: "km.h"
Fortran: "km.f03"
C interface:
double pi = acos(-1); // typical usage double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0; double y1 = 4.0, y2 = -4.0, y3 = -3.0, y4 = 3.0; // special handing double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN, e = 1.0; // print result printf("pow(1.0, 4.0) = %.15f\n", pow(x1, y1)); printf("pow(2.0, -4.0) = %.15f\n", pow(x2, y2)); printf("pow(3.0, -3.0) = %.15f\n", pow(x3, y3)); printf("pow(4.0, 3.0) = %.15f\n", pow(x4, y4)); printf("pow(1.0, 0.0) = %+.15f\n", pow(x1, a)); printf("pow(INFINITY, 1.0) = %+.15f\n", pow(b, x1)); printf("pow(-INFINITY, -1.0) = %+.15f\n", pow(c, -x1)); printf("pow(1.0, -INFINITY) = %+.15f\n", pow(x1, c)); printf("pow(1.0, NAN) = %+.15f\n", pow(x1, d)); printf("pow(NAN, -1.0) = %+.15f\n", pow(d, -x1)); /* * pow(1.0, 4.0) = 1.000000000000000 * pow(2.0, -4.0) = 0.062500000000000 * pow(3.0, -3.0) = 0.037037037037037 * pow(4.0, 3.0) = 64.000000000000000 * pow(1.0, 0.0) = +1.000000000000000 * pow(INFINITY, 1.0) = +inf * pow(-INFINITY, -1.0) = -0.000000000000000 * pow(1.0, -INFINITY) = +1.000000000000000 * pow(1.0, NAN) = +1.000000000000000 * pow(NAN, -1.0) = +nan * * */
REAL(8) :: X = 3.0 REAL(8) :: Y = -3.0 PRINT*, POW(X, Y) ! ! OUTPUT ! 0.037037037037037 !