Dotcpp  >  编程教程  >  math.h头文件  >  C语言modf()函数:求双精度数的小数部分

C语言modf()函数:求双精度数的小数部分

点击打开在线编译器,边学边练

函数名: modf

头文件:<math.h>

函数原型: double modf(double value, double *iptr);

功 能: 求双精度数的小数部分

参 数: double value   为要操作的双精度数 ,double *iptr   为要传回整数部分的变量指针

返回值: 返回value的小数部分


程序例: 分别求出双精度number的小数部分和整数部分,并将结果输出

#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



本文固定URL:https://www.dotcpp.com/course/480

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)