How to use frexp() function to get floating point value N into a normalized fraction and an integral power of two in C++

1 Answer

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

using namespace std;

int main()
{
	int i;
	double f2 = frexp(12.34, &i);
	cout << "frexp(12.34, &i) = " << f2 << " * 2^" << i << endl;

	return 0;
}


/*
run:

frexp(12.34, &i) = 0.77125 * 2^4

*/

 



answered Mar 18, 2016 by avibootz
...