You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 absolute magnitude but updates the result using Math.min(), which can produce an incorrect result.
Steps to reproduce
Add the following test to AbsoluteMinTest:
assertEquals(2, AbsoluteMin.getMinValue(-5, 2));
Excepted behavior
The method should return the value with the smallest absolute magnitude.
For the input {-5, 2}, the expected result is 2.
Steps to reproduce
No response
Excepted behavior
The method AbsoluteMin.getMinValue(int a, int b) is expected to return the number whose absolute value is smallest, not the numerically smallest number.
It should compare values using Math.abs()
It should return the original number (preserving sign) that has the minimum absolute magnitude
Activity
aryanvermaj67-sys commentedon Aug 14, 2026
will you provide the screenshot