Number_types: add regression test for to_interval(cpp_int) with large values#9410
Open
RajdeepKushwaha5 wants to merge 1 commit intoCGAL:mainfrom
Open
Number_types: add regression test for to_interval(cpp_int) with large values#9410RajdeepKushwaha5 wants to merge 1 commit intoCGAL:mainfrom
RajdeepKushwaha5 wants to merge 1 commit intoCGAL:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a regression test to ensure CGAL::to_interval(boost::multiprecision::cpp_int) correctly handles very large integer values whose double conversion would overflow to ±infinity (issue #5990), preventing reintroduction of the prior exception-throwing behavior.
Changes:
- Add a new single-source test covering large positive/negative
cpp_intvalues and some exactly representable cases. - Register the new test executable in the Number_types test CMakeLists.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Number_types/test/Number_types/to_interval_cpp_int_large.cpp | New regression test for to_interval(cpp_int) on huge magnitudes (incl. ±2^10000). |
| Number_types/test/Number_types/CMakeLists.txt | Builds the new regression test as part of the Number_types test suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… values Add a dedicated test that exercises CGAL::to_interval() on boost::multiprecision::cpp_int values whose double conversion overflows to infinity (2^10000, 2^1024, -2^10000), as well as well-behaved values (2^52, 2^100, 0). The old implementation in RET_boost_mp_base::To_interval called x.compare(double), which Boost.MP implements via convert_to<number>, throwing 'Cannot convert a non-finite number to an integer' when the double is ±infinity. The fix (integer specialization dispatching to Boost_MP_internal::to_interval, using bit-level extraction) is already in place; this test ensures it does not regress. Closes CGAL#5990
08ea260 to
5e8873d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Add a regression test for #5990.
to_interval(cpp_int)used to throw"Cannot convert a non-finite number to an integer"for values whosedoubleconversion overflows to infinity (e.g.2^10000). The old implementation inRET_boost_mp_base::To_intervalcalledx.compare(double), which Boost.Multiprecision implements viaconvert_to<number>, failing on ±infinity.The fix (integer specialization dispatching to
Boost_MP_internal::to_interval, using bit-level extraction) is already in main. This PR adds the missing regression test to ensure it does not regress, and closes the issue.Test cases:
2^10000,-2^10000,2^1024(just aboveDBL_MAX),2^52,2^100,0.Release Management