#include <stdio.h>
int main()
{
char c = 'a';
int n = c; //将c赋值给n
float f = c; //将c赋值给f
double d = c; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}
我找到答案了,因为C语言默认输出小数位数都取6位,但是小数保留10位就不一样了,double的精度更高
printf("%f\n",f);这里%f的意思是6位小数:
#include <stdio.h>
int main()
{
char c = 'a';
int n = c; //将c赋值给n
float f = n; //将c赋值给f
double d = f ; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}