Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#4 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
perl
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Perl
Stelle
0
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di trizen/Math-AnyNum

Tutte le issue di trizen/Math-AnyNum

Issue simili

Altre issue su Perl

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.