You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2005/12/30 16:35:50 UTC

svn commit: r360107 - in /incubator/harmony/enhanced/classlib/trunk/java-src/luni/src: main/java/java/lang/ main/java/java/util/ test/java/org/apache/harmony/tests/java/util/

Author: tellison
Date: Fri Dec 30 07:35:40 2005
New Revision: 360107

URL: http://svn.apache.org/viewcvs?rev=360107&view=rev
Log:
Fixes and regression test for HARMONY-22 (Double NaN should compare greater than
positive infinity) including equivalent changes required in Float, and in the sort
ordering of float and double arrays by java.util.Arrays

Added:
    incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/test/java/org/apache/harmony/tests/java/util/
    incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Double.java
    incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Float.java
    incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/util/Arrays.java

Modified: incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Double.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Double.java?rev=360107&r1=360106&r2=360107&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Double.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Double.java Fri Dec 30 07:35:40 2005
@@ -83,18 +83,37 @@
 	}
 
 	/**
-	 * Compares the receiver with the Double parameter.
+	 * Compares the receiver with the Double parameter. NaN is equal to NaN, and
+	 * is greater than other double values. 0d is greater than -0d.
 	 * 
 	 * @param object
 	 *            the Double to compare to the receiver
 	 * 
-	 * @return Returns greater than zero when this.doubleValue() >
-	 *         object.doubleValue(), zero when this.doubleValue() ==
-	 *         object.doubleValue(), and less than zero when this.doubleValue() <
-	 *         object.doubleValue()
+	 * @return Returns greater than zero when this.doubleValue() is greater than
+	 *         object.doubleValue(), zero when this.doubleValue() equals
+	 *         object.doubleValue(), and less than zero when this.doubleValue()
+	 *         is less than object.doubleValue()
 	 */
 	public int compareTo(Double object) {
-		return value > object.value ? 1 : (value < object.value ? -1 : 0);
+		long d1, d2;
+		long NaNbits = Double.doubleToLongBits(Double.NaN);
+		if ((d1 = Double.doubleToLongBits(value)) == NaNbits) {
+			if (Double.doubleToLongBits(object.value) == NaNbits) {
+				return 0;
+			}
+			return 1;
+		}
+		if ((d2 = Double.doubleToLongBits(object.value)) == NaNbits) {
+			return -1;
+		}
+		if (value == object.value) {
+			if (d1 == d2) {
+				return 0;
+			}
+			// check for -0
+			return d1 > d2 ? 1 : -1;
+		}
+		return value > object.value ? 1 : -1;
 	}
 
 	/**
@@ -103,13 +122,15 @@
 	 * @param object
 	 *            the Double to compare to the receiver
 	 * 
-	 * @return Returns greater than zero when this.doubleValue() >
-	 *         object.doubleValue(), zero when this.doubleValue() ==
-	 *         object.doubleValue(), and less than zero when this.doubleValue() <
-	 *         object.doubleValue()
+	 * @return Returns greater than zero when this.doubleValue() is greater than
+	 *         object.doubleValue(), zero when this.doubleValue() equals
+	 *         object.doubleValue(), and less than zero when this.doubleValue()
+	 *         is less than object.doubleValue()
 	 * 
 	 * @throws ClassCastException
 	 *             when object is not a Double
+	 * 
+	 * @see #compareTo(Double)
 	 */
 	public int compareTo(Object object) {
 		return compareTo((Double) object);
@@ -326,17 +347,37 @@
 	}
 
 	/**
-	 * Compares the two doubles.
+	 * Compares the two doubles. NaN is equal to NaN, and is greater than other
+	 * double values. 0d is greater than -0d.
 	 * 
 	 * @param double1
 	 *            the first value to compare
 	 * @param double2
 	 *            the second value to compare
 	 * 
-	 * @return Returns greater than zero when double1 > double2, zero when
-	 *         double1 == double2, and less than zero when double1 < double2
+	 * @return Returns greater than zero when double1 is greater than double2,
+	 *         zero when double1 equals double2, and less than zero when double1
+	 *         is less than double2
 	 */
 	public static int compare(double double1, double double2) {
-		return double1 > double2 ? 1 : (double1 < double2 ? -1 : 0);
+		long d1, d2;
+		long NaNbits = Double.doubleToLongBits(Double.NaN);
+		if ((d1 = Double.doubleToLongBits(double1)) == NaNbits) {
+			if (Double.doubleToLongBits(double2) == NaNbits) {
+				return 0;
+			}
+			return 1;
+		}
+		if ((d2 = Double.doubleToLongBits(double2)) == NaNbits) {
+			return -1;
+		}
+		if (double1 == double2) {
+			if (d1 == d2) {
+				return 0;
+			}
+			// check for -0
+			return d1 > d2 ? 1 : -1;
+		}
+		return double1 > double2 ? 1 : -1;
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Float.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Float.java?rev=360107&r1=360106&r2=360107&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Float.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/lang/Float.java Fri Dec 30 07:35:40 2005
@@ -90,18 +90,37 @@
 	}
 
 	/**
-	 * Compares the receiver with the Float parameter.
+	 * Compares the receiver with the Float parameter. NaN is equal to NaN, and
+	 * is greater than other float values. 0f is greater than -0f.
 	 * 
 	 * @param object
 	 *            the Float to compare to the receiver
 	 * 
-	 * @return Returns greater than zero when this.floatValue() >
-	 *         object.floatValue(), zero when this.floatValue() ==
-	 *         object.floatValue(), and less than zero when this.floatValue() <
-	 *         object.floatValue()
+	 * @return Returns greater than zero when this.floatValue() is greater than
+	 *         object.floatValue(), zero when this.floatValue() equals
+	 *         object.floatValue(), and less than zero when this.floatValue() is
+	 *         less than object.floatValue()
 	 */
 	public int compareTo(Float object) {
-		return value > object.value ? 1 : (value < object.value ? -1 : 0);
+		int f1, f2;
+		int NaNbits = Float.floatToIntBits(Float.NaN);
+		if ((f1 = Float.floatToIntBits(value)) == NaNbits) {
+			if (Float.floatToIntBits(object.value) == NaNbits) {
+				return 0;
+			}
+			return 1;
+		}
+		if ((f2 = Float.floatToIntBits(object.value)) == NaNbits) {
+			return -1;
+		}
+		if (value == object.value) {
+			if (f1 == f2) {
+				return 0;
+			}
+			// check for -0
+			return f1 > f2 ? 1 : -1;
+		}
+		return value > object.value ? 1 : -1;
 	}
 
 	/**
@@ -110,13 +129,15 @@
 	 * @param object
 	 *            the Float to compare to the receiver
 	 * 
-	 * @return Returns greater than zero when this.floatValue() >
-	 *         object.floatValue(), zero when this.floatValue() ==
-	 *         object.floatValue(), and less than zero when this.floatValue() <
-	 *         object.floatValue()
+	 * @return Returns greater than zero when this.floatValue() is greater than
+	 *         object.floatValue(), zero when this.floatValue() equals
+	 *         object.floatValue(), and less than zero when this.floatValue() is
+	 *         less than object.floatValue()
 	 * 
 	 * @throws ClassCastException
 	 *             when object is not a Float
+	 * 
+	 * @see #compareTo(Float)
 	 */
 	public int compareTo(Object object) {
 		return compareTo((Float) object);
@@ -331,17 +352,37 @@
 	}
 
 	/**
-	 * Compares the two floats.
+	 * Compares the two floats. NaN is equal to NaN, and is greater than other
+	 * float values. 0f is greater than -0f.
 	 * 
 	 * @param float1
 	 *            the first value to compare
 	 * @param float2
 	 *            the second value to compare
 	 * 
-	 * @return Returns greater than zero when float1 > float2, zero when float1 ==
-	 *         float2, and less than zero when float1 < float2
+	 * @return Returns greater than zero when float1 is greater than float2,
+	 *         zero when float1 equals float2, and less than zero when float1 is
+	 *         less than float2
 	 */
 	public static int compare(float float1, float float2) {
-		return float1 > float2 ? 1 : (float1 < float2 ? -1 : 0);
+		int f1, f2;
+		int NaNbits = Float.floatToIntBits(Float.NaN);
+		if ((f1 = Float.floatToIntBits(float1)) == NaNbits) {
+			if (Float.floatToIntBits(float2) == NaNbits) {
+				return 0;
+			}
+			return 1;
+		}
+		if ((f2 = Float.floatToIntBits(float2)) == NaNbits) {
+			return -1;
+		}
+		if (float1 == float2) {
+			if (f1 == f2) {
+				return 0;
+			}
+			// check for -0
+			return f1 > f2 ? 1 : -1;
+		}
+		return float1 > float2 ? 1 : -1;
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/util/Arrays.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/util/Arrays.java?rev=360107&r1=360106&r2=360107&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/util/Arrays.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/main/java/java/util/Arrays.java Fri Dec 30 07:35:40 2005
@@ -202,19 +202,20 @@
 	 *         is the -index - 1 where the element would be inserted
 	 */
 	public static int binarySearch(double[] array, double value) {
+		long longBits = Double.doubleToLongBits(value);
 		int low = 0, mid = -1, high = array.length - 1;
 		while (low <= high) {
 			mid = (low + high) >> 1;
-			if (value > array[mid])
+			if (lessThan(array[mid], value))
 				low = mid + 1;
-			else if (value == array[mid])
+			else if (longBits == Double.doubleToLongBits(array[mid]))
 				return mid;
 			else
 				high = mid - 1;
 		}
 		if (mid < 0)
 			return -1;
-		return -mid - (value < array[mid] ? 1 : 2);
+		return -mid - (lessThan(value, array[mid]) ? 1 : 2);
 	}
 
 	/**
@@ -229,19 +230,20 @@
 	 *         is the -index - 1 where the element would be inserted
 	 */
 	public static int binarySearch(float[] array, float value) {
+		int intBits = Float.floatToIntBits(value);
 		int low = 0, mid = -1, high = array.length - 1;
 		while (low <= high) {
 			mid = (low + high) >> 1;
-			if (value > array[mid])
+			if (lessThan(array[mid], value))
 				low = mid + 1;
-			else if (value == array[mid])
+			else if (intBits == Float.floatToIntBits(array[mid]))
 				return mid;
 			else
 				high = mid - 1;
 		}
 		if (mid < 0)
 			return -1;
-		return -mid - (value < array[mid] ? 1 : 2);
+		return -mid - (lessThan(value, array[mid]) ? 1 : 2);
 	}
 
 	/**
@@ -876,7 +878,8 @@
 	}
 
 	/**
-	 * Compares the two arrays.
+	 * Compares the two arrays. The values are compared in the same manner as
+	 * Float.equals().
 	 * 
 	 * @param array1
 	 *            the first float array
@@ -884,6 +887,8 @@
 	 *            the second float array
 	 * @return true when the arrays have the same length and the elements at
 	 *         each index in the two arrays are equal, false otherwise
+	 * 
+	 * @see Float#equals(Object)
 	 */
 	public static boolean equals(float[] array1, float[] array2) {
 		if (array1 == array2)
@@ -891,14 +896,17 @@
 		if (array1 == null || array2 == null || array1.length != array2.length)
 			return false;
 		for (int i = 0; i < array1.length; i++) {
-			if (array1[i] != array2[i])
+			if (Float.floatToIntBits(array1[i]) !=
+					Float.floatToIntBits(array2[i])) {
 				return false;
+			}
 		}
 		return true;
 	}
 
 	/**
-	 * Compares the two arrays.
+	 * Compares the two arrays. The values are compared in the same manner as
+	 * Double.equals().
 	 * 
 	 * @param array1
 	 *            the first double array
@@ -906,6 +914,8 @@
 	 *            the second double array
 	 * @return true when the arrays have the same length and the elements at
 	 *         each index in the two arrays are equal, false otherwise
+	 * 
+	 * @see Double#equals(Object)
 	 */
 	public static boolean equals(double[] array1, double[] array2) {
 		if (array1 == array2)
@@ -913,8 +923,10 @@
 		if (array1 == null || array2 == null || array1.length != array2.length)
 			return false;
 		for (int i = 0; i < array1.length; i++) {
-			if (array1[i] != array2[i])
+			if (Double.doubleToLongBits(array1[i]) !=
+					Double.doubleToLongBits(array2[i])) {
 				return false;
+			}
 		}
 		return true;
 	}
@@ -964,6 +976,44 @@
 		return true;
 	}
 
+	private static boolean lessThan(double double1, double double2) {
+		long d1, d2;
+		long NaNbits = Double.doubleToLongBits(Double.NaN);
+		if ((d1 = Double.doubleToLongBits(double1)) == NaNbits) {
+			return false;
+		}
+		if ((d2 = Double.doubleToLongBits(double2)) == NaNbits) {
+			return true;
+		}
+		if (double1 == double2) {
+			if (d1 == d2) {
+				return false;
+			}
+			// check for -0
+			return d1 < d2;
+		}
+		return double1 < double2;
+	}
+
+	private static boolean lessThan(float float1, float float2) {
+		int f1, f2;
+		int NaNbits = Float.floatToIntBits(Float.NaN);
+		if ((f1 = Float.floatToIntBits(float1)) == NaNbits) {
+			return false;
+		}
+		if ((f2 = Float.floatToIntBits(float2)) == NaNbits) {
+			return true;
+		}
+		if (float1 == float2) {
+			if (f1 == f2) {
+				return false;
+			}
+			// check for -0
+			return f1 < f2;
+		}
+		return float1 < float2;
+	}
+
 	private static int med3(byte[] array, int a, int b, int c) {
 		byte x = array[a], y = array[b], z = array[c];
 		return x < y ? (y < z ? b : (x < z ? c : a)) : (y > z ? b : (x > z ? c
@@ -978,14 +1028,16 @@
 
 	private static int med3(double[] array, int a, int b, int c) {
 		double x = array[a], y = array[b], z = array[c];
-		return x < y ? (y < z ? b : (x < z ? c : a)) : (y > z ? b : (x > z ? c
-				: a));
+		return lessThan(x, y)
+			? (lessThan(y, z) ? b : (lessThan(x, z) ? c : a))
+			: (lessThan(z, y) ? b : (lessThan(z, x) ? c : a));
 	}
 
 	private static int med3(float[] array, int a, int b, int c) {
 		float x = array[a], y = array[b], z = array[c];
-		return x < y ? (y < z ? b : (x < z ? c : a)) : (y > z ? b : (x > z ? c
-				: a));
+		return lessThan(x, y)
+			? (lessThan(y, z) ? b : (lessThan(x, z) ? c : a))
+			: (lessThan(z, y) ? b : (lessThan(z, x) ? c : a));
 	}
 
 	private static int med3(int[] array, int a, int b, int c) {
@@ -1231,13 +1283,16 @@
 	 * 
 	 * @param array
 	 *            the double array to be sorted
+	 * 
+	 * @see #sort(double[], int, int)
 	 */
 	public static void sort(double[] array) {
 		sort(0, array.length, array);
 	}
 
 	/**
-	 * Sorts the specified range in the array in ascending order.
+	 * Sorts the specified range in the array in ascending order. The values are
+	 * sorted according to the order imposed by Double.compareTo().
 	 * 
 	 * @param array
 	 *            the double array to be sorted
@@ -1251,6 +1306,8 @@
 	 * @exception ArrayIndexOutOfBoundsException
 	 *                when <code>start < 0</code> or
 	 *                <code>end > array.size()</code>
+	 * 
+	 * @see Double#compareTo(Double)
 	 */
 	public static void sort(double[] array, int start, int end) {
 		if (start >= 0 && end <= array.length) {
@@ -1267,7 +1324,7 @@
 		int length = end - start;
 		if (length < 7) {
 			for (int i = start + 1; i < end; i++)
-				for (int j = i; j > start && array[j - 1] > array[j]; j--) {
+				for (int j = i; j > start && lessThan(array[j], array[j - 1]); j--) {
 					temp = array[j];
 					array[j] = array[j - 1];
 					array[j - 1] = temp;
@@ -1292,7 +1349,7 @@
 		a = b = start;
 		c = d = end - 1;
 		while (true) {
-			while (b <= c && array[b] <= partionValue) {
+			while (b <= c && !lessThan(partionValue, array[b])) {
 				if (array[b] == partionValue) {
 					temp = array[a];
 					array[a++] = array[b];
@@ -1300,7 +1357,7 @@
 				}
 				b++;
 			}
-			while (c >= b && array[c] >= partionValue) {
+			while (c >= b && !lessThan(array[c], partionValue)) {
 				if (array[c] == partionValue) {
 					temp = array[c];
 					array[c] = array[d];
@@ -1341,13 +1398,16 @@
 	 * 
 	 * @param array
 	 *            the float array to be sorted
+	 * 
+	 * @see #sort(float[], int, int)
 	 */
 	public static void sort(float[] array) {
 		sort(0, array.length, array);
 	}
 
 	/**
-	 * Sorts the specified range in the array in ascending order.
+	 * Sorts the specified range in the array in ascending order. The values are
+	 * sorted according to the order imposed by Float.compareTo().
 	 * 
 	 * @param array
 	 *            the float array to be sorted
@@ -1361,6 +1421,8 @@
 	 * @exception ArrayIndexOutOfBoundsException
 	 *                when <code>start < 0</code> or
 	 *                <code>end > array.size()</code>
+	 * 
+	 * @see Float#compareTo(Float)
 	 */
 	public static void sort(float[] array, int start, int end) {
 		if (start >= 0 && end <= array.length) {
@@ -1377,7 +1439,7 @@
 		int length = end - start;
 		if (length < 7) {
 			for (int i = start + 1; i < end; i++)
-				for (int j = i; j > start && array[j - 1] > array[j]; j--) {
+				for (int j = i; j > start && lessThan(array[j], array[j - 1]); j--) {
 					temp = array[j];
 					array[j] = array[j - 1];
 					array[j - 1] = temp;
@@ -1402,7 +1464,7 @@
 		a = b = start;
 		c = d = end - 1;
 		while (true) {
-			while (b <= c && array[b] <= partionValue) {
+			while (b <= c && !lessThan(partionValue, array[b])) {
 				if (array[b] == partionValue) {
 					temp = array[a];
 					array[a++] = array[b];
@@ -1410,7 +1472,7 @@
 				}
 				b++;
 			}
-			while (c >= b && array[c] >= partionValue) {
+			while (c >= b && !lessThan(array[c], partionValue)) {
 				if (array[c] == partionValue) {
 					temp = array[c];
 					array[c] = array[d];

Added: incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java?rev=360107&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/java-src/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java Fri Dec 30 07:35:40 2005
@@ -0,0 +1,162 @@
+package org.apache.harmony.tests.java.util;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+public class ArraysTest extends TestCase {
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(double[], double)
+	 */
+	public void test_binarySearch$DD() {
+		double[] specials = new double[] { Double.NEGATIVE_INFINITY,
+				-Double.MAX_VALUE, -2d, -Double.MIN_VALUE, -0d, 0d,
+				Double.MIN_VALUE, 2d, Double.MAX_VALUE,
+				Double.POSITIVE_INFINITY, Double.NaN };
+
+		for (int i = 0; i < specials.length; i++) {
+			int result = Arrays.binarySearch(specials, specials[i]);
+			assertTrue("Assert 0: " + specials[i] + " invalid: " + result,
+					result == i);
+		}
+		assertTrue("Assert 1: Invalid search index for -1d",
+				Arrays.binarySearch(specials, -1d) == -4);
+		assertTrue("Assert 2: Invalid search index for 1d",
+				Arrays.binarySearch(specials, 1d) == -8);
+	}
+	
+	/**
+	 * @tests java.util.Arrays#binarySearch(float[], float)
+	 */
+	public void test_binarySearch$FF() {
+		float[] specials = new float[] { Float.NEGATIVE_INFINITY,
+				-Float.MAX_VALUE, -2f, -Float.MIN_VALUE, -0f, 0f,
+				Float.MIN_VALUE, 2f, Float.MAX_VALUE, Float.POSITIVE_INFINITY,
+				Float.NaN };
+
+		for (int i = 0; i < specials.length; i++) {
+			int result = Arrays.binarySearch(specials, specials[i]);
+			assertTrue("Assert 0: " + specials[i] + " invalid: " + result,
+					result == i);
+		}
+		assertTrue("Assert 1: Invalid search index for -1f",
+				Arrays.binarySearch(specials, -1f) == -4);
+		assertTrue("Assert 2: Invalid search index for 1f",
+				Arrays.binarySearch(specials, 1f) == -8);
+	}
+	
+	/**
+	 * @tests java.util.Arrays#equals(double[], double[])
+	 */
+	public void test_equals$D$D() {
+		double d[] = new double[100];
+		double x[] = new double[100];
+		Arrays.fill(d, Double.MAX_VALUE);
+		Arrays.fill(x, Double.MIN_VALUE);
+
+		assertTrue("Assert 0: Inequal arrays returned true", !Arrays.equals(d, x));
+
+		Arrays.fill(x, Double.MAX_VALUE);
+		assertTrue("Assert 1: equal arrays returned false", Arrays.equals(d, x));
+
+		assertTrue("Assert 2: should be false",
+				!Arrays.equals(new double[] { 1.0 }, new double[] { 2.0 }));
+
+		assertTrue("Assert 3: NaN not equals",
+				Arrays.equals(new double[] { Double.NaN }, new double[] { Double.NaN }));
+		assertTrue("Assert 4: 0d equals -0d",
+				!Arrays.equals(new double[] { 0d }, new double[] { -0d }));
+	}
+	
+	/**
+	 * @tests java.util.Arrays#equals(float[], float[])
+	 */
+	public void test_equals$F$F() {
+		float d[] = new float[100];
+		float x[] = new float[100];
+		Arrays.fill(d, Float.MAX_VALUE);
+		Arrays.fill(x, Float.MIN_VALUE);
+
+		assertTrue("Assert 0: Inequal arrays returned true", !Arrays.equals(d, x));
+
+		Arrays.fill(x, Float.MAX_VALUE);
+		assertTrue("Assert 1: equal arrays returned false", Arrays.equals(d, x));
+
+		assertTrue("Assert 2: NaN not equals",
+				Arrays.equals(new float[] { Float.NaN }, new float[] { Float.NaN }));
+		assertTrue("Assert 3: 0f equals -0f",
+				!Arrays.equals(new float[] { 0f }, new float[] { -0f }));
+	}
+	
+	/**
+	 * @tests java.util.Arrays#sort(double[])
+	 */
+	public void test_sort$D() {
+		// Test a basic sort
+		double[] reversedArray = new double[100];
+		for (int counter = 0; counter < reversedArray.length; counter ++)
+			reversedArray[counter] = (double)(reversedArray.length - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < reversedArray.length; counter ++) {
+			assertTrue("Assert 0: Resulting array not sorted",
+					reversedArray[counter] == (double)counter);
+		}
+
+		// These have to sort as per the Double compare ordering
+		double[] specials1 = new double[]{Double.NaN, Double.MAX_VALUE, Double.MIN_VALUE, 0d, -0d, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY};
+		double[] specials2 = new double[]{0d, Double.POSITIVE_INFINITY, -0d, Double.NEGATIVE_INFINITY, Double.MIN_VALUE, Double.NaN, Double.MAX_VALUE};
+		double[] answer = new double[]{Double.NEGATIVE_INFINITY, -0d, 0d, Double.MIN_VALUE, Double.MAX_VALUE, Double.POSITIVE_INFINITY, Double.NaN};
+
+		Arrays.sort(specials1);
+		Object[] print1 = new Object[specials1.length];
+		for (int i = 0; i < specials1.length; i++) {
+			print1[i] = new Double(specials1[i]);
+		}
+		assertTrue("Assert 1: specials sort incorrectly" + Arrays.asList(print1),
+				Arrays.equals(specials1, answer));
+
+		Arrays.sort(specials2);
+		Object[] print2 = new Object[specials2.length];
+		for (int i = 0; i < specials2.length; i++)
+			print2[i] = new Double(specials2[i]);
+		assertTrue("Assert 2: specials sort incorrectly " + Arrays.asList(print2), 
+				Arrays.equals(specials2, answer));
+	}
+	
+	/**
+	 * @tests java.util.Arrays#sort(float[])
+	 */
+	public void test_sort$F() {
+		// Test a basic sort
+		float[] reversedArray = new float[100];
+		for (int counter = 0; counter < reversedArray.length; counter ++) {
+			reversedArray[counter] = (float)(reversedArray.length - counter - 1);
+		}
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < reversedArray.length; counter ++) {
+			assertTrue("Assert 0: Resulting array not sorted",
+					reversedArray[counter] == (float)counter);
+		}
+
+		float[] specials1 = new float[]{Float.NaN, Float.MAX_VALUE, Float.MIN_VALUE, 0f, -0f, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY};
+		float[] specials2 = new float[]{0f, Float.POSITIVE_INFINITY, -0f, Float.NEGATIVE_INFINITY, Float.MIN_VALUE, Float.NaN, Float.MAX_VALUE};
+		float[] answer = new float[]{Float.NEGATIVE_INFINITY, -0f, 0f, Float.MIN_VALUE, Float.MAX_VALUE, Float.POSITIVE_INFINITY, Float.NaN};
+
+		Arrays.sort(specials1);
+		Object[] print1 = new Object[specials1.length];
+		for (int i = 0; i < specials1.length; i++) {
+			print1[i] = new Float(specials1[i]);
+		}
+		assertTrue("Assert 1: specials sort incorrectly" + Arrays.asList(print1),
+				Arrays.equals(specials1, answer));
+
+		Arrays.sort(specials2);
+		Object[] print2 = new Object[specials2.length];
+		for (int i = 0; i < specials2.length; i++) {
+			print2[i] = new Float(specials2[i]);
+		}
+		assertTrue("Assert 2: specials sort incorrectly" + Arrays.asList(print2), 
+				Arrays.equals(specials2, answer));
+	}
+}