# modf()

Declaration

`double modf(double dX, double* dpInteger);`

Description:

This function splits the value dX into its intger part (*ipInteger) and fractional part (the return value). The integer and fractional parts have the same sign as dX.

```float modf(float, float*);
double modf(double, double*);
long double modf(long double, long double*);```

Related Functions

```float modff(float, float*);
long double modfl(long double, long double*);```

* Note: Since C does not allow function overloading, these other versions of this function exist.

 Domain (-∞, ∞) Range (-1, 1) X Integers Periodicity None Symmetry None Asymptotes None

Example

```#include <iostream>
#include <cmath>

int main() {
using namespace std;

double dX = -1.2;
double dInteger;
cout << "x = " << dX << "  Fraction = " << modf(dX, &dInteger);
cout << "  Integer = " << dInteger << endl;

dX = 6.2;
cout << "x = " << dX << "  Fraction = " << modf(dX, &dInteger);
cout << "  Integer = " << dInteger << endl;

return 0;
}```

Output: