C Reference function frexp()

Usage of frexp():

double frexp(double x, int *exponent);

Parameters:

The floating-point number x is broken up into a mantissa and exponent.The returned value is the mantissa and the integer pointed to by exponent is the exponent. The resultant value is x=mantissa * 2^exponent.

Return value:

The mantissa is in the range of .5 (inclusive) to 1 (exclusive)

Source code example of frexp():


	#include<stdio.h>
	#include<math.h>

	main()
	{
		double input, output;
		int i;

		input = 10.0;
		output = frexp (input , &i);
		printf ("%lf * 2^%d = %f\n", output, i, input);
		return 0;
	}

Output of the frexp example program above:


	0.625000 * 2^4 = 10.000000

This entry was posted in C Reference math.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.