Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AbsoluteMax bug for equal absolute values #6142

Closed

Conversation

rizwan-ilyas
Copy link
Contributor

The AbsoluteMax class contains a bug in the getMaxValue method. When two numbers have the same absolute value (e.g., 5 and -5), the method returns the number that appears later in the array. This behavior is inconsistent and may lead to unexpected results.

Explanation with Example.

Before Fix
5, -5 returns -5
-5, 5 returns 5

After Fix
5, -5 returns 5
-5, 5 returns 5

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

Thanks

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.83%. Comparing base (466ff0b) to head (09561f5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6142      +/-   ##
============================================
+ Coverage     73.80%   73.83%   +0.02%     
- Complexity     5144     5156      +12     
============================================
  Files           660      661       +1     
  Lines         17669    17687      +18     
  Branches       3404     3409       +5     
============================================
+ Hits          13041    13059      +18     
  Misses         4120     4120              
  Partials        508      508              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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