Fix integer overflow in AbsoluteValue.getAbsValue for Integer.MIN_VALUE - #7604
Open
arsam4waffels wants to merge 1 commit into
Open
Fix integer overflow in AbsoluteValue.getAbsValue for Integer.MIN_VALUE#7604arsam4waffels wants to merge 1 commit into
arsam4waffels wants to merge 1 commit into
Conversation
arsam4waffels
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
September 13, 2026 16:44
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7604 +/- ##
============================================
- Coverage 81.12% 81.10% -0.02%
+ Complexity 7816 7814 -2
============================================
Files 827 827
Lines 24742 24742
Branches 4833 4833
============================================
- Hits 20072 20068 -4
- Misses 3906 3907 +1
- Partials 764 767 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
clang-format -i --style=file path/to/your/file.javaProblem
Math.abs(Integer.MIN_VALUE) returns Integer.MIN_VALUE due to overflow,
since 2,147,483,648 exceeds the int range.
Fix
Changed parameter and return type from int to long to handle this edge case correctly.
Test
Updated testMinIntEdgeCase to verify correct behavior.