C 库函数 - modf()

C 语言教程 · 2019-02-23 09:26:51

描述

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

声明

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

double modf(double x, double *integer)

参数

  • x -- 浮点值。
  • integer -- 指向一个对象的指针,该对象存储了整数部分。

返回值

该函数返回 x 的小数部分,符号与 x 相同。

实例

下面的实例演示了 modf() 函数的用法。

#include<stdio.h>
#include<math.h>

int main ()
{
   double x, fractpart, intpart;

   x = 8.123456;
   fractpart = modf(x, &intpart);

   printf("整数部分 = %lf\n", intpart);
   printf("小数部分 = %lf \n", fractpart);
   
   return(0);
}

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

整数部分 = 8.000000
小数部分 = 0.123456 

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Understanding Machine Learning

Understanding Machine Learning

Shai Shalev-Shwartz、Shai Ben-David / Cambridge University Press / 2014 / USD 48.51

Machine learning is one of the fastest growing areas of computer science, with far-reaching applications. The aim of this textbook is to introduce machine learning, and the algorithmic paradigms it of......一起来看看 《Understanding Machine Learning》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具