Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.11
-
None
Description
The ArrayUtils.contains (float [], Float.NaN) and ArrayUtils.indexOf (float [], Float.NaN) methods do not handle correctly when the array contains Float.NaN. It should return that finds the element, but instead returns -1.
For example, consider the following:
@Test public void testContainsFloatNaN() { float[] a = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, Float.POSITIVE_INFINITY }; assertTrue(ArrayUtils.contains(a, Float.POSITIVE_INFINITY)); assertTrue(ArrayUtils.contains(a, Float.NEGATIVE_INFINITY)); assertTrue(ArrayUtils.contains(a, Float.NaN)); // Error }
And
@Test public void testIndexOfFloatNaN() { float[] array = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, Float.POSITIVE_INFINITY, Float.NaN }; assertEquals(0, ArrayUtils.indexOf(array, Float.NEGATIVE_INFINITY)); assertEquals(1, ArrayUtils.indexOf(array, Float.NaN)); // Error assertEquals(2, ArrayUtils.indexOf(array, Float.POSITIVE_INFINITY)); }
Attachments
Issue Links
- is related to
-
LANG-1541 ArrayUtils.contains() fails to handle Double.NaN
- Resolved
- links to