C语言双精度浮点余数:fmod()
例子
此函数返回的除法的浮点余数x/y。返回的值与x相同。
#include <math.h> /* for fmod() */
#include <stdio.h> /* for printf() */
int main(void)
{
double x = 10.0;
double y = 5.1;
double modulus = fmod(x, y);
printf("%lf\n", modulus); /* f is the same as lf. */
return 0;
}输出:
4.90000
重要:请谨慎使用此函数,因为由于浮点值的操作,它可能返回意外的值。
#include <math.h>
#include <stdio.h>
int main(void)
{
printf("%f\n", fmod(1, 0.1));
printf("%19.17f\n", fmod(1, 0.1));
return 0;
}输出:
0.1 0.09999999999999995
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短