使用 float 时,我的程序是这样的。
#include <stdio.h>
int main() {
float result;
float input;
scanf("%f", &input);
result = input / .25;
printf("%f", result);
return 0;
}
输入数值 3,输出就是 12.000。但把 float 换成 double 后,结果却始终是 0.000。我是不是漏掉了什么?
从英语翻译·查看原文With float my program looks like this:
#include <stdio.h>
int main() {
float result;
float input;
scanf("%f", &input);
result = input / .25;
printf("%f", result);
return 0;
}
Entering the value 3 produces 12.000 as output. Replacing float with double, however, consistently gives me 0.000 instead. Is there something I'm overlooking here?