modf函数

modf函数

函数头文件:#include “math.h”

函数用途:把一个双精度浮点数分解成为整数和小数!

函数原型:

double modf (      double x,      double * intpart );
long double modf ( long double x, long double * intpart );
float modf (       float x,       float * intpart );

例子->输出结果 :3.141593 = 3.000000 + 0.141593

[cpp]

#include <stdio.h>
#include <math.h>
int main ()
{
double p, f, i;
p = 3.141593;
f = modf (p , &i);
printf (“%lf = %lf + %lf \n”, p, i, f);
return 0;
}

[/cpp]