cbrt, cbrtf, cbrtl

计算立方根。

语法

double cbrt(
   double x
);
float cbrt(
   float x
);  // C++ only
long double cbrt(
   long double x
);  // C++ only
float cbrtf(
   float x
);
long double cbrtl(
   long double x
);
#define cbrt(X) // Requires C11 or higher

参数

x
浮点值

返回值

cbrt 函数返回 x 的立方根。

输入 SEH 异常 _matherr 异常
± QNAN、IND、INF

备注

由于 C++ 允许重载,因此你可以调用采用 cbrtfloat 类型的 long double 重载。 在 C 程序中,除非使用 <tgmath.h> 宏调用此函数,否则 cbrt 始终采用并返回 double

如果使用 <tgmath.h>cbrt() 宏,则参数的类型将决定选择哪个版本的函数。 有关详细信息,请参阅泛型类型数学

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

要求

函数 C 标头 C++ 标头
cbrt, cbrtf, cbrtl <math.h> <cmath>
cbrt <tgmath.h>

有关兼容性的详细信息,请参阅 兼容性

示例

// crt_cbrt.c
// Compile using: cl /W4 crt_cbrt.c
// This program calculates a cube root.

#include <math.h>
#include <stdio.h>

int main( void )
{
   double question = -64.64;
   double answer;

   answer = cbrt(question);
   printf("The cube root of %.2f is %.6f\n", question, answer);
}
The cube root of -64.64 is -4.013289

另请参阅

数学和浮点支持
expexpfexpl
loglogflog10log10f
powpowfpowl