Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Issue with Math::AnyNum workaround for mpc-1.4.0 ui/fr division bug.

未关闭
#4 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
perl
领域
backend

调研方向

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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

trizen/Math-AnyNum 的其他 Issue

查看 trizen/Math-AnyNum 的全部 Issue

相似的 Issue

更多 Perl Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。