该函数返回给定数字的指数部分,即logx的整数部分。
ilogb()函数等效于(int)logb()
int ilogb(float x); int ilogb(double x); int ilogb(long double x); int ilogb(integral x);
x :这是要计算其指数的值。
参数 | 返回值 |
---|---|
x=0 | -INT_MIN |
x=NAN or +inf or _inf | INT_MAX |
让我们看一个简单的例子
#include <iostream> #include<math.h> #include<float.h> using namespace std; int main() { int x=4; std::cout << "Value of x is : " <<x<< std::endl; cout<<"Exponent value of x is : "<<ilogb(x); return 0; }
输出:
Value of x is : 4 Exponent value of x is : 2
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)