首页 > 应用开发 > > 哪个大神帮忙解答一下!
float和double的用法区别 顺便帮我看看这两个代码。用double赋值后输出都是0.
#include <stdio.h>
main()
{
float x;
scanf("%f",&x);
x=(int)(x*100+0.5)/100.0;
printf("%0.3f",x);
}
#include <stdio.h>
main()
{
double x;
scanf("%f",&x);
x=(int)(x*100+0.5)/100.0;
printf("%0.3f",x);
}来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4479/viewspace-3145450/ ,如需转载,请注明出处,否则将追究法律责任。