目录

double modf(double x, double *integer)

描述 (Description)

C库函数double modf(double x, double *integer)返回小数部分(小数点后的部分),并将整数设置为整​​数分量。

声明 (Declaration)

以下是modf()函数的声明。

double modf(double x, double *integer)

参数 (Parameters)

  • x - 这是浮点值。

  • integer - 这是指向要存储整数部分的对象的指针。

返回值 (Return Value)

此函数返回x的小数部分,具有相同的符号。

例子 (Example)

以下示例显示了modf()函数的用法。

#include<stdio.h>
#include<math.h>
int main () {
   double x, fractpart, intpart;
   x = 8.123456;
   fractpart = modf(x, &intpart);
   printf("Integral part = %lf\n", intpart);
   printf("Fraction Part = %lf \n", fractpart);
   return(0);
}

让我们编译并运行上面的程序,它将产生以下结果 -

Integral part = 8.000000
Fraction Part = 0.123456 
↑回到顶部↑
WIKI教程 @2018