C++ frexp()

Last Updated On Saturday 16th Apr 2022

The frexp() function breaks the floating point number x into its binary significand (a floating point with an absolute value between 0.5(included) and 1.0(excluded)) and an integral exponent for 2.


	frexp(double x, int* exp)


The frexp() takes two arguments.

  • x – The value to be decomposed.
  • exp – Pointer to an int where the value of the exponent is stored.

Return value

Returns the binary significand whose absolute value lies in the interval [0.5, 1].

If x is zero, both significand and exponent are zero.

frexp() prototype [As of C++ 11 standard]

	double frexp (double x, int* exp);
float frexp (float x, int* exp);
long double frexp (long double x, int* exp);
double frexp (T x, int* exp);

Example : C++ frexp()

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

int main () {
  double param, result;
  int n;
  param = 4.0;
  result = frexp(param , &n);
  printf ("%f = %f * 2^%d\n", param, result, n);
  return 0;


	4.000000 = 0.500000 * 2^3