Skip to content

Restore caller rounding state in Float::Rounding and FloatVal - #262

Merged
zayenz merged 3 commits into
mainfrom
feature/6.5.0-float-median-rounding
Oct 22, 2026
Merged

zayenz merged 3 commits into
mainfrom
feature/6.5.0-float-median-rounding

Conversation

@zayenz

@zayenz zayenz commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Float::Rounding initialized its arithmetic policy before Boost could save the incoming rounding mode, and its own destructor did not restore it. This leaked the mode from direct rounding scopes and FloatVal operations.

Separate the arithmetic operations from the state-saving policy. Float::Rounding now uses Boost's state saver around the complete operations base, so it saves before initialization and restores on destruction. FloatVal uses that policy directly. Boost's unprotected policy retains Gecode's arithmetic and MPFR operations. The MSVC/SSE path keeps its explicit-direction arithmetic and uses the same single outer state saver.

Move the existing overflow-safe median calculation into the rounding operations; FloatVal::med() delegates to it. Regressions cover direct and nested scopes, outward rounding, direct and Boost-wrapped interval operations, unprotected MPFR calls, and median boundaries under all four rounding modes. Infinite-input cases run only when compiler flags support them. Related to #155.

Validation: all 1,557 float tests and all 484 integrity tests pass on the final build. The focused regressions also pass with five iterations and five threads. The regression bodies also pass with Autoconf finite-math flags and with the standard-rounding arithmetic used on Windows. Source tidiness and generated-source freshness checks pass. Native Windows/MSVC validation runs in the existing CI matrix.

This changes the rounding policy layout and moves the MPFR entry points to its operations base; ABI versioning remains part of the release flow.

@zayenz
zayenz force-pushed the feature/6.5.0-float-median-rounding branch from a5d5c94 to e21ebe8 Compare October 22, 2026 12:02
@zayenz
zayenz force-pushed the feature/6.5.0-float-median-rounding branch from e21ebe8 to 57fdaa4 Compare October 22, 2026 13:54
@zayenz zayenz changed the title Preserve the caller's rounding mode in FloatVal median queries Restore caller rounding state in Float::Rounding and FloatVal Oct 22, 2026
@zayenz
zayenz merged commit eff2b7e into main Oct 22, 2026
16 checks passed
@zayenz
zayenz deleted the feature/6.5.0-float-median-rounding branch October 22, 2026 17:09
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.

1 participant