modf
double  modf ( double x , double * ipart );
math.h
  cplusplus.com  

Split floating-point value into fractional and integer parts.
  Breaks x in two parts: the integer (stored in location pointed by ipart) and the fraction (return value).

Parameters.

x
Floating point value.
ipart
Location where the integer part of x will be stored.

Return Value.
  Fractional part of x

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.

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

main ()
{
  double param, fractpart, intpart;

  param = 3.14159265;
  fractpart = modf (param , &intpart);
  printf ("%lf = %lf + %lf \n", param, intpart, fractpart);
  return 0;
}
Output:
3.141593 = 3.000000 + 0.141593

See also.
  ldexp, frexp


© The C++ Resources Network, 2000