Issue with Math::AnyNum workaround for mpc-1.4.0 ui/fr division bug.
还没有人认领这个 Issue。
评估
调研方向
Start in AnyNum.pm around line 2536 and inspect the workaround for Math::MPC division, then review the related mpc_ui/fr_div calls in MPC.xs. Compare behavior with mpc-1.4.0 and earlier versions, including an imaginary component of -0. Done means the workaround preserves the intended signed-zero result without breaking compatibility with older MPC versions.
由索引模型根据 Issue 内容生成。
描述
I see that in AnyNum.pm, at around line 2536, you have replaced:
Math::MPC::Rmpc_ui_div($r, 1, $x, $ROUND);
with:
Math::MPC::Rmpc_set_ui($r, 1, $ROUND);
Math::MPC::Rmpc_div($r, $r, $x, $ROUND);
For (and only for) the case that the imaginary component of $x is 0:
If building against mpc-1.3.x or earlier, both Math::MPC::Rmpc_ui_div($r, 1, $x, $ROUND) and its replacement code set the imaginary part of $r, to 0.
However, beginning with mpc-1.4.0, a correction has been made that has the "Rmpc_ui_div" form set that imaginary part to -0, whilst leaving the behaviour of that "replacement code" unchanged.
The same would apply to a similar workaround with Rmpc_fr_div.
(This, of course, was the change that introduced the bug you discovered.)
IOW, when built against mpc-1.4.0, your replacement code will set the imaginary part to 0, though it should set that part to -0 (given that it's intended to replace "Rmpc_ui_div").
It's actually ok with me if you don't want to do anything about this. The values being returned are essentially correct - the only discrepancy is the sign of zero.
And, as it stands, it is consistent with the (incorrect) behaviour of Rmpc_ui/fr_div in the mpc-1.3.x library (and earlier).
Feel free to close this ticket if you're not fussed about it.
AFAIK, Math-MPC-1.42 works efficiently around the division bug.
The macros that do the fixing are defined only if the mpc version is 1.4.0. For all other versions, Rmpc_fr_div and Rmpc_ui_div are unchanged. I've also applied the same fix for mpc_ui/fr_div calls that are made elsewhere in MPC.xs.
However, Math-MPC-1.42 doesn't fix that incorrectness of Rmpc_/ui/fr_div when built against mpc-1.3.x or earlier.
That shouldn't be hard to address - I'll do that in Math-MPC-1.43. (I wish I had thought of doing that before I released 1.42.)
Reminder to self: Need to also handle the case where the imaginary part of $x is -0.
- 主要语言
- Perl
- 星标
- 0
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
trizen/Math-AnyNum 的其他 Issue
-
gaussian未关闭
难度 5/5 一周以上 新手友好度 25/100
trizen/Math-AnyNum#2 · 2 条评论 ·
查看 trizen/Math-AnyNum 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 3 天内回复
-
documentation Needs Triage
难度 1/5 1 小时以内 新手友好度 93/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
curl/everything-curl#658 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
PDLPorters/pdl#561 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
objectionary/eolang.sty#197 ·
维护者通常 2 天内回复