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 例外 |
---|---|---|
± INF、QNaN、IND | none | none |
備註
因為 C++ 允許多載,所以您可以呼叫採用 cbrt
和 float
類型的 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
另請參閱
數學和浮點支援
exp
, expf
, expl
log
, logf
, log10
, log10f
pow
, powf
, powl
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應