Syntax
#include <math.h> double modf(double x, double *intptr);Description
modf breaks down the floating-point value x into fractional and integral parts. The signed fractional portion of x is returned. The integer portion is stored as a double value pointed to by intptr. Both the fractional and integral parts are given the same sign as x.
modf returns the signed fractional portion of x.
This example breaks the floating-point number -14.876 into its fractional and integral components.
#include <math.h> int main(void) { double x,y,d; x = -14.876; y = modf(x, &d); printf("x = %lf\n", x); printf("Integral part = %lf\n", d); printf("Fractional part = %lf\n", y); return 0; /**************************************************************************** The output should be: x = -14.876000 Integral part = -14.000000 Fractional part = -0.876000 ****************************************************************************/ }Related Information