为什么?
11979999 / 10000 = 1197.999877930
和
printf("%f\n", static_cast<double>(((float)11979999 / (float)10000)));
代替
1197.9999
以及如何解决?
在您的代码中,您以单精度进行了计算,然后将结果转换为双精度。如果要双精度,请以双精度进行计算:
printf("%f\n", (double)11979999 / (double)10000);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句