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 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.
Screenshots
No response
Additional context
No response
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 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.
Screenshots
No response
Additional context
No response