Table of Contents

modf

    double modf(double , double *int);

Splits completely paid off and returns the fractional part of x.

cpp Sourcecode Example

#include <iostream> /* including standard library */
#include <cmath> /* including math library */
 
using namespace std;
int main ( void )
{
  double i, result;
  result=modf(4.2, &i);
 
  //cout.setf(ios::fixed, ios::floatfield);
  cout.precision(8);
 
  cout << i << " + " << result << " = 4.2 " << endl;
  return 0;
}

output

  4 + 0.2 = 4.2