frexp
double  frexp ( double x , int * exp );
math.h
  cplusplus.com  

Get mantissa and exponent of floating-point value.
  Calculates mantissa (a floating-point value between 0.5 and 1) and exponent (an integer value), such that:
    x = mantissa * 2exponent
  where x is parameter x, mantissa is the value returned by the function and exponent is set by the function at location pointed by exp.

Parameters.

x
Floating point value
exp
Location where to exponent will be received.

Return Value.
  Mantissa.

Portability.
  Defined in ANSI-C.
  ANSI-C++ adds float and double overloaded versions of this function, with the same bahavior but being both, parameter x and return value, of one of these types.

Example.

/* frexp example */
#include <stdio.h>
#include <math.h>

main ()
{
  double param, result;
  int n;

  param = 15.2;
  result = frexp (param , &n);
  printf ("%f * 2^%d = %f\n", result, n, param);
  return 0;
}
Output:
0.950000 * 2^4 = 15.200000

See also.
  ldexp, modf, exp


© The C++ Resources Network, 2000