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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短