Skip to content

回复:错误报告:舍入故障 ​

原始发布页

打开来源页面
查看 1 个交叉存档

这一定是 getinfo 转换成浮点数以返回 JSON-RPC 结果时产生的舍入误差。唯一使用浮点数表示金额的地方,就是在 JSON-RPC 中返回数值时。

1.139999999999 的位数超过了比特币内部能够表示的长度。

在内部,它只可能是: 1.13999999 或 1.14000000

1.139999999999 比起 1.13999999 要接近 1.14000000 得多,所以它一定是 1.14000000。

代码是: (double)GetBalance() / (double)COIN.

(我暂时想不到简便的修复方法)

英文原文 ​

展开英文原文

It must be a rounding error when getinfo converts to floating point to return the JSON-RPC result. The only place where it uses floating point to represent money is returning a value in JSON-RPC.

1.139999999999 is longer than bitcoin can internally represent.

internally, it could only be: 1.13999999 or 1.14000000

1.139999999999 is much much closer to 1.14000000 than 1.13999999, so it must be 1.14000000.

The code is this: (double)GetBalance() / (double)COIN.

(I can't think of an easy way to fix it at the moment)

为历史保存,为中文读者整理。每篇档案均附来源与英文原文。