ilogb、 、 ilogbfilogbl

擷取代表指定值之非偏誤基底 2 指數的整數。

語法

int ilogb(
   double x
);

int ilogb(
   float x
); //C++ only

int ilogb(
   long double x
); //C++ only

int ilogbf(
   float x
);

int ilogbl(
   long double x
);

#define ilogbl(X) // Requires C11 or higher

參數

x
指定值。

傳回值

如果成功,這些函式會以 值傳回的base-2指數xsigned int

否則,函式會傳回math.h>中<定義的下列其中一個值:

輸入 結果
±0 FP_ILOGB0
± INF、± NAN、IND FP_ILOGBNAN

_matherr 中的指定回報錯誤。

備註

因為 C++ 允許多載,所以您可以呼叫採用並傳回 ilogbfloat 類型的 long double 的多載。 在 C 程式中,除非您使用 <tgmath.h> 巨集來呼叫此函式,否則 ilogb 一律會採用並傳回 double

如果您使用 <tgmath.h>ilogb() 巨集,則引數的型別會決定選取哪一個函式版本。 如需詳細資料,請參閱型別泛型數學

呼叫此函式類似於呼叫對應的 logb 函式,然後將傳回值轉型成 int

需求

常式 C 標頭 C++ 標頭
ilogb、 、 ilogbfilogbl <math.h> <cmath>
ilogb 巨集 <tgmath.h>

如需相容性詳細資訊,請參閱相容性

另請參閱

依字母順序排列的函式參考
frexp
logb、、 logbflogbl_logb_logbf