How to use ilogb() function to extract the value of the exponent from the floating-point argument in C++

1 Answer

0 votes
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	cout << "ilogb(12.34) = " << ilogb(12.34) << endl;
	cout << "ilogb(100.0) = " << ilogb(100.0) << endl;
	cout << "ilogb(0.0) = " << ilogb(0.0) << endl;

	return 0;
}


/*
run:

ilogb(12.34) = 3
ilogb(100.0) = 6
ilogb(0.0) = -2147483648

*/

 



answered Mar 19, 2016 by avibootz
...