mirror of
https://github.com/apache/commons-math.git
synced 2025-02-13 13:35:56 +00:00
MATH-482 FastMath.max(50.0f, -50.0f) => -50.0f; should be +50.0f
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X@1060065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d3dda59bef
commit
7aabd3b5a2
@ -3479,7 +3479,7 @@ public class FastMath {
|
|||||||
* @return b if a is lesser or equal to b, a otherwise
|
* @return b if a is lesser or equal to b, a otherwise
|
||||||
*/
|
*/
|
||||||
public static float max(final float a, final float b) {
|
public static float max(final float a, final float b) {
|
||||||
return (a <= b) ? b : (Float.isNaN(a + b) ? Float.NaN : b);
|
return (a <= b) ? b : (Float.isNaN(a + b) ? Float.NaN : a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compute the maximum of two values
|
/** Compute the maximum of two values
|
||||||
|
@ -52,6 +52,10 @@ The <action> type attribute can be add,update,fix,remove.
|
|||||||
If the output is not quite correct, check for invisible trailing spaces!
|
If the output is not quite correct, check for invisible trailing spaces!
|
||||||
-->
|
-->
|
||||||
<release version="2.2" date="TBD" description="TBD">
|
<release version="2.2" date="TBD" description="TBD">
|
||||||
|
<action dev="sebb" type="fix" issue="MATH-482">
|
||||||
|
FastMath.max(50.0f, -50.0f) => -50.0f; should be +50.0f
|
||||||
|
Fixed FastMath.max(float, float) so it returns correct value.
|
||||||
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-467">
|
<action dev="luc" type="fix" issue="MATH-467">
|
||||||
Fixed an awkward statement that triggered a false positive warning.
|
Fixed an awkward statement that triggered a false positive warning.
|
||||||
</action>
|
</action>
|
||||||
|
@ -76,18 +76,18 @@ public class FastMathTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMinMaxFloat() {
|
public void testMinMaxFloat() {
|
||||||
double[][] pairs = {
|
float[][] pairs = {
|
||||||
{ -50.0, 50.0 },
|
{ -50.0f, 50.0f },
|
||||||
{ Float.POSITIVE_INFINITY, 1.0 },
|
{ Float.POSITIVE_INFINITY, 1.0f },
|
||||||
{ Float.NEGATIVE_INFINITY, 1.0 },
|
{ Float.NEGATIVE_INFINITY, 1.0f },
|
||||||
{ Float.NaN, 1.0 },
|
{ Float.NaN, 1.0f },
|
||||||
{ Float.POSITIVE_INFINITY, 0.0 },
|
{ Float.POSITIVE_INFINITY, 0.0f },
|
||||||
{ Float.NEGATIVE_INFINITY, 0.0 },
|
{ Float.NEGATIVE_INFINITY, 0.0f },
|
||||||
{ Float.NaN, 0.0 },
|
{ Float.NaN, 0.0f },
|
||||||
{ Float.NaN, Float.NEGATIVE_INFINITY },
|
{ Float.NaN, Float.NEGATIVE_INFINITY },
|
||||||
{ Float.NaN, Float.POSITIVE_INFINITY }
|
{ Float.NaN, Float.POSITIVE_INFINITY }
|
||||||
};
|
};
|
||||||
for (double[] pair : pairs) {
|
for (float[] pair : pairs) {
|
||||||
Assert.assertEquals("min(" + pair[0] + ", " + pair[1] + ")",
|
Assert.assertEquals("min(" + pair[0] + ", " + pair[1] + ")",
|
||||||
Math.min(pair[0], pair[1]),
|
Math.min(pair[0], pair[1]),
|
||||||
FastMath.min(pair[0], pair[1]),
|
FastMath.min(pair[0], pair[1]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user