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
Usability for the Web
Tom Brinck、Darren Gergle、Scott D. Wood / Morgan Kaufmann / 2001-10-15 / USD 65.95
Every stage in the design of a new web site is an opportunity to meet or miss deadlines and budgetary goals. Every stage is an opportunity to boost or undercut the site's usability. Thi......一起来看看 《Usability for the Web》 这本书的介绍吧!