Skip to content

fix: return infinity for hypot overflow#151

Open
bhagy-patel1 wants to merge 1 commit into
Rinzii:mainfrom
bhagy-patel1:fix/hypot-overflow
Open

fix: return infinity for hypot overflow#151
bhagy-patel1 wants to merge 1 commit into
Rinzii:mainfrom
bhagy-patel1:fix/hypot-overflow

Conversation

@bhagy-patel1

Copy link
Copy Markdown

Summary

Fixes #137

Previously, ccm::hypot returned the largest finite floating-point value
when the true result exceeded the representable range, instead of returning
+inf like std::hypot does.

Changes

  • Added an overflow check in hypot_impl.hpp before the final multiply:
    if x > max / scale, return +inf directly
  • Added #include <limits> required for the overflow check
  • Added a regression test HypotOverflowBoundary in hypot_cbrt_test.cpp

Note

This PR replaces #141, which was closed due to merge conflicts with the
updated main branch. The branch has been rebased onto the latest main.

@bhagy-patel1 bhagy-patel1 requested a review from Rinzii as a code owner June 14, 2026 07:44
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.

[BUG]: hypot generic kernel returns max-finite instead of inf at the overflow boundary

1 participant