cbrt
计算x的立方根。
接口定义
C interface:
float cbrtf(float x);
double cbrt(double x);
double cbrt_18(double x);
long double cbrtl(long double x);
cbrt_18仅在高精度版本提供。
Fortran interface:
RES = CBRTF(X);
RES = CBRT(X);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 输入x为±0,返回±0。
- 输入x为±∞,返回±∞。
- 输入x为nan,返回nan。
依赖
C: "km.h"
示例
C interface:
// typical usage double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0; // special handing double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN; // print result printf("cbrt(1.0) = %.15f\n", cbrt(x1)); printf("cbrt(2.0) = %.15f\n", cbrt(x2)); printf("cbrt(3.0) = %.15f\n", cbrt(x3)); printf("cbrt(4.0) = %.15f\n", cbrt(x4)); printf("cbrt(0.0) = %.15f\n", cbrt(a)); printf("cbrt(INFINITY) = %.15f\n", cbrt(b)); printf("cbrt(-INFINITY) = %.15f\n", cbrt(c)); printf("cbrt(NAN) = %.15f\n", cbrt(d)); /* * * cbrt(1.0) = 1.000000000000000 * cbrt(2.0) = 1.259921049894873 * cbrt(3.0) = 1.442249570307408 * cbrt(4.0) = 1.587401051968200 * cbrt(0.0) = 0.000000000000000 * cbrt(INFINITY) = inf * cbrt(-INFINITY) = -inf * cbrt(NAN) = nan * */
Fortran interface:
REAL(8) :: X = 3.0 PRINT*, CBRT(X) ! ! OUTPUT ! 1.442249570307408 !
父主题: 幂和根函数