SN-1363 已核对来源,附原文与上下文。
一定是 getinfo 转成浮点数返回 JSON-RPC 结果时的舍入误差。唯一用浮点数表示钱的地方就是返回 JSON-RPC 值。
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 比 bitcoin 内部能表示的更长。
1.139999999999 is longer than bitcoin can internally represent.
内部只可能是:
internally, it could only be:
1.13999999 或
1.13999999 or
1.14000000
1.14000000
1.139999999999 离 1.14000000 比离 1.13999999 近得多,所以一定是 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.
(double)GetBalance() / (double)COIN.
(一时想不出简单的修法)
(I can't think of an easy way to fix it at the moment)