我喜欢在C中使用浮点数时更改显示的小数位数.是否与FLT_DIG定义的值有关float.h?如果是这样,我怎么能把它从6改为10?
我得到的数字0.000000与实际值相似0.0000003455.
eps*_*lon 15
这里有两个不同的问题:存储的浮点数的精度,这是通过使用floatvs 确定的double,然后是这样打印的数字的精度:
float foo = 0.0123456789;
printf("%.4f\n", foo); // This will print 0.0123 (4 digits).
double bar = 0.012345678912345;
printf("%.10lf\n", bar); // This will print 0.0123456789
Run Code Online (Sandbox Code Playgroud)