小编And*_*ane的帖子

为什么我的BigDecimal对象初始化时出现意外的舍入错误?

在Ruby 2.2.0中,为什么:

BigDecimal.new(34.13985572755337, 9)
Run Code Online (Sandbox Code Playgroud)

平等34.0但是

BigDecimal.new(34.13985572755338, 9)
Run Code Online (Sandbox Code Playgroud)

平等34.1398557

请注意,我在64位计算机上运行它.

ruby floating-point rounding bigdecimal floating-point-precision

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