Skip to content

Use rintl for long double in to_int - #71

Open
reach2sayan wants to merge 1 commit into
boostorg:developfrom
reach2sayan:fix/long-double-to-int
Open

reach2sayan wants to merge 1 commit into
boostorg:developfrom
reach2sayan:fix/long-double-to-int

Conversation

@reach2sayan

Copy link
Copy Markdown
Contributor

Fixes #67.

rounding_control<long double>::to_int called rint, the double function, in three backends, so a long double was rounded to 53 bits before it was rounded to an integer. Above 2^53, int_down and int_up returned wrong values, sometimes on the wrong side of the argument, and fmod, which uses int_down, returned intervals that do not contain the true result: fmod(2^60 + 1, 1) gave [1, 1].

Not affected: 32-bit x86 (x87 frndint), and targets where long double is double (MSVC, 32-bit ARM).

Test: test_long_double() in test/fmod.cpp checks that fmod(2^60 + 1, 1) contains 0. It is skipped when long double has fewer than 62 significant bits.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.85%. Comparing base (3a640df) to head (4c46d2c).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #71      +/-   ##
===========================================
+ Coverage    82.79%   82.85%   +0.06%     
===========================================
  Files           23       23              
  Lines         1017     1021       +4     
  Branches       412      414       +2     
===========================================
+ Hits           842      846       +4     
  Misses         167      167              
  Partials         8        8              
Files with missing lines Coverage Δ
...umeric/interval/detail/c99sub_rounding_control.hpp 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a640df...4c46d2c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

fmod of interval<long double> can miss the true result

1 participant