Title: [BUG]
Open Graph Title: [BUG]
X Title: [BUG]
Description: Description The current implementation of com.thealgorithms.maths.AbsoluteMin returns an incorrect result for some inputs. Example: org.opentest4j.AssertionFailedError: Expected :2 Actual :-5 The implementation compares values by their a...
Open Graph Description: Description The current implementation of com.thealgorithms.maths.AbsoluteMin returns an incorrect result for some inputs. Example: org.opentest4j.AssertionFailedError: Expected :2 Actual :-5 The i...
X Description: Description The current implementation of com.thealgorithms.maths.AbsoluteMin returns an incorrect result for some inputs. Example: org.opentest4j.AssertionFailedError: Expected :2 Actual :-5 The i...
Opengraph URL: https://github.com/TheAlgorithms/Java/issues/7537
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] \u003ctitle\u003e","articleBody":"### Description\n\nThe current implementation of com.thealgorithms.maths.AbsoluteMin returns an incorrect result for some inputs.\n\nExample:\n\norg.opentest4j.AssertionFailedError:\nExpected :2\nActual :-5\n\nThe implementation compares values by their absolute magnitude but updates the result using Math.min(), which can produce an incorrect result.\n\nSteps to reproduce\nAdd the following test to AbsoluteMinTest:\n\nassertEquals(2, AbsoluteMin.getMinValue(-5, 2));\n\nExcepted behavior\nThe method should return the value with the smallest absolute magnitude.\n\nFor the input {-5, 2}, the expected result is 2.\n\n\n\n### Steps to reproduce\n\n_No response_\n\n### Excepted behavior\n\nThe method AbsoluteMin.getMinValue(int a, int b) is expected to return the number whose absolute value is smallest, not the numerically smallest number.\n\nIt should compare values using Math.abs()\nIt should return the original number (preserving sign) that has the minimum absolute magnitude\n\n### Screenshots\n\n_No response_\n\n### Additional context\n\n_No response_","author":{"url":"https://github.com/nikhil-codes-tech","@type":"Person","name":"nikhil-codes-tech"},"datePublished":"2026-07-22T14:07:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/7537/Java/issues/7537"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7266c5c2-951f-7c0c-84a9-95f8f2b217bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED76:FE622:4AB561:6689EC:6A62D432 |
| html-safe-nonce | a796bea1d80c2d05cd0c159e61e4619617242645e63000f2af8c774da770b78b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDc2OkZFNjIyOjRBQjU2MTo2Njg5RUM6NkE2MkQ0MzIiLCJ2aXNpdG9yX2lkIjoiMzIyOTI3NDYwMzI3NDgxODYxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ad23520f4b8188e965be48a1676aaba4d0082042233d235999cfe0f78650481 |
| hovercard-subject-tag | issue:4949772202 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/TheAlgorithms/Java/7537/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebb4e2c663bc533f8c325d141a9990e108334802ea9c04d206eda14d0bd6844f/TheAlgorithms/Java/issues/7537 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebb4e2c663bc533f8c325d141a9990e108334802ea9c04d206eda14d0bd6844f/TheAlgorithms/Java/issues/7537 |
| og:image:alt | Description The current implementation of com.thealgorithms.maths.AbsoluteMin returns an incorrect result for some inputs. Example: org.opentest4j.AssertionFailedError: Expected :2 Actual :-5 The i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nikhil-codes-tech |
| hostname | github.com |
| expected-hostname | github.com |
| None | df33b1b61ee7b9a0af988199bfc3503c9c1acafb1f1d40e1f140ea7c84f890dd |
| turbo-cache-control | no-preview |
| go-import | github.com/TheAlgorithms/Java git https://github.com/TheAlgorithms/Java.git |
| octolytics-dimension-user_id | 20487725 |
| octolytics-dimension-user_login | TheAlgorithms |
| octolytics-dimension-repository_id | 63477660 |
| octolytics-dimension-repository_nwo | TheAlgorithms/Java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 63477660 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/Java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d41cd1bdb290013455c0ac430fa755621733f5eb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width