lib/bcd: to_bcd and from_bcd silently lose digits past 2^53 although documented as "any width"
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with lib/bcd.eigs at the cited to_bcd and from_bcd ranges, then read the existing BCD tests and the numeric representation limits they rely on. Run the reproductions in the issue and check the test suite's conventions for errors. Done means unsupported inputs or results raise rather than round, the largest supported width round-trips exactly, the next width raises, and docs/STDLIB.md:406 states the limit.
由索引模型根据 Issue 内容生成。
描述
Found by the read-only lib/ audit (hq RULES.md, audit area 4). Reproduced on main at d3ec498.
What's wrong
docs/STDLIB.md:406 and lib/bcd.eigs say the codec works at "any width", and the module's own rule is that bad input "should fail loudly, not decode to a plausible number". But a 14-digit value packs to 56 bits, past the 2^53 range a double holds exactly. to_bcd (lib/bcd.eigs:35-48) rounds the packed result, and from_bcd (lib/bcd.eigs:19-33) decodes the rounded value to a different number with no error.
Repro
load_file of "lib/bcd.eigs"
print of (from_bcd of (to_bcd of 9999999999999))
print of (from_bcd of (to_bcd of 99999999999999))
print of (to_bcd of 99999999999999)
Actual:
9999999999999
99999999999998
4.323455642275676e+16
Expected: the second line is 99999999999999, and the third is the exact value 0x99999999999999 (43234556422756761). Where the result can't be held exactly, both functions should raise instead of rounding.
Note: Phase 2 (#1776, exact int64) may make widths up to 15 digits exact. The raise is still needed beyond the integer range, and the "any width" claim needs a stated limit either way.
Done when
-
to_bcdandfrom_bcdraise when the input or the result is outside the exactly representable integer range, and docs/STDLIB.md:406 states that limit instead of "any width". - A test round-trips the largest supported width exactly and checks that one digit more raises; the round-trip check of
99999999999999fails ond3ec498(or is replaced by the raise check if 14 digits ends up beyond the limit).
— Duet (orchestrator)
- 主要语言
- C
- 星标
- 3
- 派生
- 7
- 平均合并
- 6 小时 32 分钟
- 30 天内合并 PR
- 285
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
InauguralSystems/EigenScript 的其他 Issue
-
good first issue needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
InauguralSystems/EigenScript#2347 · 1 条评论 ·
维护者通常 1 天内回复
-
needs-triage
难度 1/5 1 小时以内 新手友好度 82/100
InauguralSystems/EigenScript#2335 · 1 条评论 ·
维护者通常 1 天内回复
-
area:embed kind:bug
难度 2/5 1-3 小时 新手友好度 62/100
InauguralSystems/EigenScript#2311 · 1 条评论 ·
维护者通常 1 天内回复
-
area:gates kind:gate-defect
难度 2/5 1-3 小时 新手友好度 62/100
InauguralSystems/EigenScript#2305 · 1 条评论 ·
维护者通常 1 天内回复
-
area:ci bug found-by:duet-audit
难度 2/5 1-3 小时 新手友好度 62/100
InauguralSystems/EigenScript#2283 ·
维护者通常 1 天内回复
查看 InauguralSystems/EigenScript 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
FujiNetWIFI/fujinet-config#379 ·
维护者通常 1 天内回复
-
Ship /Local/Applications, the Local domain's Applications folder可能已有人在做 @pkgdemon 今天认领。 未关闭area:base enhancement
难度 1/5 1 小时以内 新手友好度 94/100
nextbsd/nextbsd-userland#612 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
zephyrproject-rtos/zephyr#125543 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
colbymchenry/codegraph#3277 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100