C语言里的modf函数 怎么用??

来源:百度知道 编辑:UC知道 时间:2024/06/08 20:27:28
详细些~

函数名:modf
头文件:<math.h>
函数原型:double modf(double x, double *ipart)
函数用途:分解x,以得到x的整数和小数部分
输入参数:x 待分解的数
输出参数:ipath x 的整数部分
返回值:x 的小数部分

实例:
#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
",number, integer, fraction);
return