modf() General Function modf() Separate integral part and fraction double modf(real, ip) double real, *ip; modf is the floating-point modulus function. It returns the fractional part of its argument real, which is a value f in the range 0 <= f < 1. It also stores the integral part in the double location referenced by ip. These numbers satisfy the equation real = f + *ip. ***** Example ***** This example prompts for a number from the keyboard, then uses modf to calculate the number's fractional portion. #include <stdio.h> main() { extern char *gets(); extern double modf(), atof(); double real, fp, ip; char string[64]; for (;;) { printf("Enter number: "); if (gets(string) == 0) break; real = atof(string); fp = modf(real, &ip); printf("%lf is the integral part of %lf\n", ip, real); printf("%lf is the fractional part of %lf\n", fp, real); } } ***** See Also ***** atof(), ceil(), fabs(), floor(), frexp(), general function, ldexp() COHERENT Lexicon Page 1