計算立方根。
語法
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 later
參數
x
浮點值。
傳回值
cbrt 函式會傳回 x 的立方根。
輸入
SEH 例外狀況
_matherr 例外
± INF、QNaN、IND
none
none
備註
因為 C++ 允許多載,所以您可以呼叫採用 cbrt 和 float 類型的 long double 的多載。 在 C 程式中,除非您使用
如果您使用
根據預設,此函式的全域狀態會限定於應用程式。 若要變更此行為,請參閱 CRT 中的全域狀態。
需求
函式
C 標頭
C++ 標頭
cbrt、 、 cbrtfcbrtl
cbrt 巨集
如需相容性詳細資訊,請參閱相容性。
範例
// crt_cbrt.c
// Compile using: cl /W4 crt_cbrt.c
// This program calculates a cube root.
#include
#include
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
另請參閱
數學與浮點支援
exp、 、 expfexpl
log、 、 logf、 log10log10f
pow、 、 powfpowl