Skip to content

Conversation

ckormanyos
Copy link
Member

This is intended to repair #652, which I believe is an actual bug. The upper-bound check was missing on the unsigned version of the conversion routine (it was already present for the signed case).

@ckormanyos ckormanyos requested a review from jzmaddock April 29, 2025 08:18
@jzmaddock
Copy link
Collaborator

Thanks Chris, yes your fix looks correct to me!

@ckormanyos
Copy link
Member Author

yes your fix looks correct to me!

John, I was pondering this fix. You know, I did not (yet) explicitly or purposely handle the case of negative cpp_bin_float when converting to unsigned long long. Do you know what should happen for this conversion? I could program the behavior now in this PR if it's incorrect.

@jzmaddock
Copy link
Collaborator

Ugh, always another corner case! I guess since we saturate, then zero would be the logical choice?

If they aren't there already, we should have some consistent tests (by which I mean that are run for all the integer backends) for all this. I can't remember off the top of my head where I put conversion tests (for saturation especially) - whether they are in test_arithmetic.hpp with everything else, or in the separate conversion testers.

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.1%. Comparing base (c433245) to head (e3b50cf).
Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop    #684     +/-   ##
=========================================
+ Coverage     94.1%   94.1%   +0.1%     
=========================================
  Files          279     280      +1     
  Lines        28983   29067     +84     
=========================================
+ Hits         27257   27342     +85     
+ Misses        1726    1725      -1     
Files with missing lines Coverage Δ
include/boost/multiprecision/cpp_bin_float.hpp 89.6% <100.0%> (-0.1%) ⬇️
include/boost/multiprecision/cpp_dec_float.hpp 94.1% <100.0%> (+0.1%) ⬆️
test/git_issue_652.cpp 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

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

@ckormanyos
Copy link
Member Author

Ugh, always another corner case! I guess since we saturate, then zero would be the logical choice?

Indeed! OK, I'm working on it....

I just ran some tests on cpp_dec_float, cpp_bin_float and built-in double, such as here at godbolt.

I will make bin-float behave the same as dec-float and double. I'll go ahead and pack the code and its tests right in this PR while we are on such a roll.

@ckormanyos
Copy link
Member Author

Hi John (@jzmaddock) so now cpp_dec_float and cpp_bin_float behave closer to how they should and seemingly identically with each other regarding overflow/underflow of integral conversions. I added the relevant tests to the Jamfile and they are all cycling green now.

I am purposely not looking into gmp_float and mpfr_float in this particular matter at this time. But I've made a note to take a cursory glance at their behaviors. I'll also keep this and these tests in mind if we ever get back to cpp_double_fp_backend.

@ckormanyos ckormanyos merged commit 0acb5b4 into develop Apr 29, 2025
80 checks passed
@ckormanyos ckormanyos deleted the issue652 branch April 29, 2025 15:32
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