C++ Math ilogb()
C++ Math ilogb()
该函数返回给定数字的指数部分,即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或+ inf或_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