Zat*_*t42 13 c floating-point precision
有人可以解释一下如何用C函数选择浮点精度吗?
例子:
theFatFunction(0.666666666, 3) 返回0.667
theFatFunction(0.111111111, 3) 返回0.111
Dan*_*ego 13
您不能这样做,因为精度由数据类型(即float或double或long double)决定.如果要将其舍入以进行打印,可以使用正确的格式说明符printf(),即printf("%0.3f\n", 0.666666666).
| 归档时间: |
|
| 查看次数: |
57152 次 |
| 最近记录: |