小编sme*_*oan的帖子

C#Math.Round bug?

我试图将数字四舍五入到小数点后7位,但我注意到Math.Round在某些​​数字上无法正常工作:

Math.Round(39.248779999999996,3) => 39.249
Math.Round(39.248779999999996,4) => 39.2488
Math.Round(39.248779999999996,5) => 39.248779999999996
Math.Round(39.248779999999996,6) => 39.248779999999996
Math.Round(39.248779999999996,7) => 39.248779999999996
Run Code Online (Sandbox Code Playgroud)

谁能向我解释这种行为?

c# math rounding

1
推荐指数
1
解决办法
1393
查看次数

标签 统计

c# ×1

math ×1

rounding ×1