modf, modfl
raw OCR
Splits a double or long double into integer and fractional parts.
Defined in header <math.h>
Syntax
#include <math.h>
double modf(double x, double *ipart);
long double modfl(long double x, long double *ipart);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| modf | ■ | ■ | ■ | ■ | |
| modfl | ■ | ■ |
Remarks
modf breaks the double x into two parts: the integer and the fraction. modf stores the integer in ipart and returns the fraction. modfl is the long double version; it takes long double arguments and returns a long double result.
Return value
modf and modfl return the fractional part of x.
See also
Example
include <math.h>
#include <stdio.h>
int main(void)
{
double fraction, integer, number = 100000.567;
fraction = modf(number, &integer);
printfC'The whole and fractional parts of %lf are %lf and %lf\n", number,
integer, fraction);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/math.h/modf/
· short form /3.1/modf/