main()
{
float a,b,d,e,f;
a=0.3;
b=0.6;
d=a*8;
e=3-d;
f=e/b; /*到这里f正好等于1.0*/
printf("%d and %f\n",(int)f,f);
system("pause");
}
打印的结果是:0 and 1.000000
为什么取整没取到1呢?
在这个式子里 怎样才能取到1呢?
main()
{
float a,b,d,e,f;
a=0.3;
b=0.6;
d=a*8;
e=3-d;
f=e/b; /*到这里f正好等于1.0*/
printf("%d and %f\n",(int)f,f);
system("pause");
}
打印的结果是:0 and 1.000000
为什么取整没取到1呢?
在这个式子里 怎样才能取到1呢?
转载于:https://www.cnblogs.com/fengyanlover/p/5292388.html