Skip to content

Fix MPFR/MPFI precision bugs and missing validation#88

Merged
msoos merged 2 commits intosynthfrom
copilot/sub-pr-85
Mar 11, 2026
Merged

Fix MPFR/MPFI precision bugs and missing validation#88
msoos merged 2 commits intosynthfrom
copilot/sub-pr-85

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

Found and fixed several bugs in the MPFI interval arithmetic integration and MPFR precision handling.

Type truncation in FGenMPFComplex

  • Constructor parameter was uint16_t but member is mpfr_prec_t (long). Values like --mpfrprec 100000 silently truncate to 34464 via 100000 & 0xFFFF.
// Before
explicit FGenMPFComplex(uint16_t _prec) : prec(_prec) {}
// After
explicit FGenMPFComplex(mpfr_prec_t _prec) : prec(_prec) {}

Wrong precision in digit_precision_mpfi()

  • Used mpfr_init() (MPFR default 53-bit) for temporaries extracting interval endpoints. High-precision intervals lose precision, making endpoints appear identical and reporting bogus maximum digit precision. Now uses mpfr_init2() with the interval's actual precision.

Missing --mpfrprec validation

  • No lower bound check. MPFR requires minimum precision of 2 bits; passing 0 or negative causes undefined behavior in mpfr_init2/mpfi_init2.

Default precision in compute_collision_prob()

  • All MPFR temporaries used mpfr_init_set_*() (53-bit default) instead of explicit 256-bit precision matching the rest of the collision probability and log-printing code.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…R init calls, missing mpfrprec validation

Co-authored-by: msoos <1334841+msoos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues with Ganak synthesis and MPFI integration Fix MPFR/MPFI precision bugs and missing validation Mar 11, 2026
@msoos msoos marked this pull request as ready for review March 11, 2026 21:17
@msoos msoos merged commit 26ae7ee into synth Mar 11, 2026
@msoos msoos deleted the copilot/sub-pr-85 branch March 11, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants