#include <math.h>
double modf( double num, double *i );
函数将参数 num 分割为整数和小数,返回小数部分并将整数部分赋给 i。
#include <math.h>
#include <stdio.h>
int main(void)
{
double fraction, integer;
double number = 100000.567;
fraction = modf(number, &integer);
printf("The whole and fractional parts of %lf are %lf and %lf\n",
number, integer, fraction);
return 0;
}输出结果:
The whole and fractional parts of 100000.567000 are 100000.000000 and 0.567000