Bitcointalk · BUG Report: Rounding glitch

中本聪,2010 年 7 月 17 日

SN-1363 已核对来源,附原文与上下文。

阅读语言
中文译文

一定是 getinfo 转成浮点数返回 JSON-RPC 结果时的舍入误差。唯一用浮点数表示钱的地方就是返回 JSON-RPC 值。

1.139999999999 比 bitcoin 内部能表示的更长。

内部只可能是: 1.13999999 或 1.14000000

1.139999999999 离 1.14000000 比离 1.13999999 近得多,所以一定是 1.14000000。

代码是这样的: (double)GetBalance() / (double)COIN.

(一时想不出简单的修法)

ORIGINAL · 英文原文
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)
上下文
← 上一条 SN-1363 · 当前 下一条 → 在档案中查看完整主题串 →
来源
Bitcointalk 原始链接 ↗ 记录编号 SN-1363