Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 33942 invoked from network); 30 Apr 2009 06:03:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Apr 2009 06:03:40 -0000 Received: (qmail 19268 invoked by uid 500); 30 Apr 2009 06:03:40 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 19185 invoked by uid 500); 30 Apr 2009 06:03:40 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 19111 invoked by uid 99); 30 Apr 2009 06:03:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2009 06:03:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2009 06:03:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A45E12388979; Thu, 30 Apr 2009 06:03:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r770078 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/builder/ java/org/apache/commons/lang/math/ java/org/apache/commons/lang/mutable/ test/org/apache/commons/lang/math/ Date: Thu, 30 Apr 2009 06:03:17 -0000 To: commits@commons.apache.org From: bayard@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090430060318.A45E12388979@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bayard Date: Thu Apr 30 06:03:16 2009 New Revision: 770078 URL: http://svn.apache.org/viewvc?rev=770078&view=rev Log: Removing NumberUtils.compare(float,float) and NumberUtils.compare(double,double). These are now foud in Float and Double respectively. Keeping the unit tests, but pointing to the JDK methods as a regression. LANG-492 Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java?rev=770078&r1=770077&r2=770078&view=diff ============================================================================== --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java Thu Apr 30 06:03:16 2009 @@ -589,7 +589,7 @@ if (comparison != 0) { return this; } - comparison = NumberUtils.compare(lhs, rhs); + comparison = Double.compare(lhs, rhs); return this; } @@ -610,7 +610,7 @@ if (comparison != 0) { return this; } - comparison = NumberUtils.compare(lhs, rhs); + comparison = Float.compare(lhs, rhs); return this; } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java?rev=770078&r1=770077&r2=770078&view=diff ============================================================================== --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java Thu Apr 30 06:03:16 2009 @@ -1180,131 +1180,6 @@ //----------------------------------------------------------------------- /** - *

Compares two doubles for order.

- * - *

This method is more comprehensive than the standard Java greater - * than, less than and equals operators.

- *
    - *
  • It returns -1 if the first value is less than the second.
  • - *
  • It returns +1 if the first value is greater than the second.
  • - *
  • It returns 0 if the values are equal.
  • - *
- * - *

- * The ordering is as follows, largest to smallest: - *

    - *
  • NaN - *
  • Positive infinity - *
  • Maximum double - *
  • Normal positive numbers - *
  • +0.0 - *
  • -0.0 - *
  • Normal negative numbers - *
  • Minimum double (-Double.MAX_VALUE) - *
  • Negative infinity - *
- *

- * - *

Comparing NaN with NaN will - * return 0.

- * - * @param lhs the first double - * @param rhs the second double - * @return -1 if lhs is less, +1 if greater, - * 0 if equal to rhs - */ - public static int compare(double lhs, double rhs) { - if (lhs < rhs) { - return -1; - } - if (lhs > rhs) { - return +1; - } - // Need to compare bits to handle 0.0 == -0.0 being true - // compare should put -0.0 < +0.0 - // Two NaNs are also == for compare purposes - // where NaN == NaN is false - long lhsBits = Double.doubleToLongBits(lhs); - long rhsBits = Double.doubleToLongBits(rhs); - if (lhsBits == rhsBits) { - return 0; - } - // Something exotic! A comparison to NaN or 0.0 vs -0.0 - // Fortunately NaN's long is > than everything else - // Also negzeros bits < poszero - // NAN: 9221120237041090560 - // MAX: 9218868437227405311 - // NEGZERO: -9223372036854775808 - if (lhsBits < rhsBits) { - return -1; - } else { - return +1; - } - } - - /** - *

Compares two floats for order.

- * - *

This method is more comprehensive than the standard Java greater than, - * less than and equals operators.

- *
    - *
  • It returns -1 if the first value is less than the second. - *
  • It returns +1 if the first value is greater than the second. - *
  • It returns 0 if the values are equal. - *
- * - *

The ordering is as follows, largest to smallest: - *

    - *
  • NaN - *
  • Positive infinity - *
  • Maximum float - *
  • Normal positive numbers - *
  • +0.0 - *
  • -0.0 - *
  • Normal negative numbers - *
  • Minimum float (-Float.MAX_VALUE) - *
  • Negative infinity - *
- * - *

Comparing NaN with NaN will return - * 0.

- * - * @param lhs the first float - * @param rhs the second float - * @return -1 if lhs is less, +1 if greater, - * 0 if equal to rhs - */ - public static int compare(float lhs, float rhs) { - if (lhs < rhs) { - return -1; - } - if (lhs > rhs) { - return +1; - } - //Need to compare bits to handle 0.0 == -0.0 being true - // compare should put -0.0 < +0.0 - // Two NaNs are also == for compare purposes - // where NaN == NaN is false - int lhsBits = Float.floatToIntBits(lhs); - int rhsBits = Float.floatToIntBits(rhs); - if (lhsBits == rhsBits) { - return 0; - } - //Something exotic! A comparison to NaN or 0.0 vs -0.0 - //Fortunately NaN's int is > than everything else - //Also negzeros bits < poszero - //NAN: 2143289344 - //MAX: 2139095039 - //NEGZERO: -2147483648 - if (lhsBits < rhsBits) { - return -1; - } else { - return +1; - } - } - - //----------------------------------------------------------------------- - /** *

Checks whether the String contains only * digit characters.

* Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java?rev=770078&r1=770077&r2=770078&view=diff ============================================================================== --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java Thu Apr 30 06:03:16 2009 @@ -267,8 +267,8 @@ * range by double comparison */ public boolean containsDouble(double value) { - int compareMin = NumberUtils.compare(getMinimumDouble(), value); - int compareMax = NumberUtils.compare(getMaximumDouble(), value); + int compareMin = Double.compare(getMinimumDouble(), value); + int compareMax = Double.compare(getMaximumDouble(), value); return compareMin <= 0 && compareMax >= 0; } @@ -303,8 +303,8 @@ * range by float comparison */ public boolean containsFloat(float value) { - int compareMin = NumberUtils.compare(getMinimumFloat(), value); - int compareMax = NumberUtils.compare(getMaximumFloat(), value); + int compareMin = Float.compare(getMinimumFloat(), value); + int compareMax = Float.compare(getMaximumFloat(), value); return compareMin <= 0 && compareMax >= 0; } Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java?rev=770078&r1=770077&r2=770078&view=diff ============================================================================== --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java Thu Apr 30 06:03:16 2009 @@ -303,7 +303,7 @@ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; - return NumberUtils.compare(value, anotherVal); + return Double.compare(value, anotherVal); } /** Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java?rev=770078&r1=770077&r2=770078&view=diff ============================================================================== --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java Thu Apr 30 06:03:16 2009 @@ -304,7 +304,7 @@ public int compareTo(Object obj) { MutableFloat other = (MutableFloat) obj; float anotherVal = other.value; - return NumberUtils.compare(value, anotherVal); + return Float.compare(value, anotherVal); } /** Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java?rev=770078&r1=770077&r2=770078&view=diff ============================================================================== --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java Thu Apr 30 06:03:16 2009 @@ -775,188 +775,189 @@ assertEquals(high, NumberUtils.max(high, mid, high), 0.0001f); } + // Testing JDK against old Lang functionality public void testCompareDouble() { - assertTrue(NumberUtils.compare(Double.NaN, Double.NaN) == 0); - assertTrue(NumberUtils.compare(Double.NaN, Double.POSITIVE_INFINITY) == +1); - assertTrue(NumberUtils.compare(Double.NaN, Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Double.NaN, 1.2d) == +1); - assertTrue(NumberUtils.compare(Double.NaN, 0.0d) == +1); - assertTrue(NumberUtils.compare(Double.NaN, -0.0d) == +1); - assertTrue(NumberUtils.compare(Double.NaN, -1.2d) == +1); - assertTrue(NumberUtils.compare(Double.NaN, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Double.NaN, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, Double.NaN) == -1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY) == 0); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, 1.2d) == +1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, 0.0d) == +1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, -0.0d) == +1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, -1.2d) == +1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(Double.MAX_VALUE, Double.NaN) == -1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, Double.MAX_VALUE) == 0); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, 1.2d) == +1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, 0.0d) == +1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, -0.0d) == +1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, -1.2d) == +1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Double.MAX_VALUE, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(1.2d, Double.NaN) == -1); - assertTrue(NumberUtils.compare(1.2d, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(1.2d, Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(1.2d, 1.2d) == 0); - assertTrue(NumberUtils.compare(1.2d, 0.0d) == +1); - assertTrue(NumberUtils.compare(1.2d, -0.0d) == +1); - assertTrue(NumberUtils.compare(1.2d, -1.2d) == +1); - assertTrue(NumberUtils.compare(1.2d, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(1.2d, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(0.0d, Double.NaN) == -1); - assertTrue(NumberUtils.compare(0.0d, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(0.0d, Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(0.0d, 1.2d) == -1); - assertTrue(NumberUtils.compare(0.0d, 0.0d) == 0); - assertTrue(NumberUtils.compare(0.0d, -0.0d) == +1); - assertTrue(NumberUtils.compare(0.0d, -1.2d) == +1); - assertTrue(NumberUtils.compare(0.0d, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(0.0d, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(-0.0d, Double.NaN) == -1); - assertTrue(NumberUtils.compare(-0.0d, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(-0.0d, Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(-0.0d, 1.2d) == -1); - assertTrue(NumberUtils.compare(-0.0d, 0.0d) == -1); - assertTrue(NumberUtils.compare(-0.0d, -0.0d) == 0); - assertTrue(NumberUtils.compare(-0.0d, -1.2d) == +1); - assertTrue(NumberUtils.compare(-0.0d, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(-0.0d, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(-1.2d, Double.NaN) == -1); - assertTrue(NumberUtils.compare(-1.2d, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(-1.2d, Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(-1.2d, 1.2d) == -1); - assertTrue(NumberUtils.compare(-1.2d, 0.0d) == -1); - assertTrue(NumberUtils.compare(-1.2d, -0.0d) == -1); - assertTrue(NumberUtils.compare(-1.2d, -1.2d) == 0); - assertTrue(NumberUtils.compare(-1.2d, -Double.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(-1.2d, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, Double.NaN) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, 1.2d) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, 0.0d) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, -0.0d) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, -1.2d) == -1); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, -Double.MAX_VALUE) == 0); - assertTrue(NumberUtils.compare(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, Double.NaN) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, 1.2d) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, 0.0d) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, -0.0d) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, -1.2d) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, -Double.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY) == 0); + assertTrue(Double.compare(Double.NaN, Double.NaN) == 0); + assertTrue(Double.compare(Double.NaN, Double.POSITIVE_INFINITY) == +1); + assertTrue(Double.compare(Double.NaN, Double.MAX_VALUE) == +1); + assertTrue(Double.compare(Double.NaN, 1.2d) == +1); + assertTrue(Double.compare(Double.NaN, 0.0d) == +1); + assertTrue(Double.compare(Double.NaN, -0.0d) == +1); + assertTrue(Double.compare(Double.NaN, -1.2d) == +1); + assertTrue(Double.compare(Double.NaN, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(Double.NaN, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.NaN) == -1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY) == 0); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.MAX_VALUE) == +1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, 1.2d) == +1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, 0.0d) == +1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, -0.0d) == +1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, -1.2d) == +1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(Double.MAX_VALUE, Double.NaN) == -1); + assertTrue(Double.compare(Double.MAX_VALUE, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(Double.MAX_VALUE, Double.MAX_VALUE) == 0); + assertTrue(Double.compare(Double.MAX_VALUE, 1.2d) == +1); + assertTrue(Double.compare(Double.MAX_VALUE, 0.0d) == +1); + assertTrue(Double.compare(Double.MAX_VALUE, -0.0d) == +1); + assertTrue(Double.compare(Double.MAX_VALUE, -1.2d) == +1); + assertTrue(Double.compare(Double.MAX_VALUE, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(Double.MAX_VALUE, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(1.2d, Double.NaN) == -1); + assertTrue(Double.compare(1.2d, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(1.2d, Double.MAX_VALUE) == -1); + assertTrue(Double.compare(1.2d, 1.2d) == 0); + assertTrue(Double.compare(1.2d, 0.0d) == +1); + assertTrue(Double.compare(1.2d, -0.0d) == +1); + assertTrue(Double.compare(1.2d, -1.2d) == +1); + assertTrue(Double.compare(1.2d, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(1.2d, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(0.0d, Double.NaN) == -1); + assertTrue(Double.compare(0.0d, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(0.0d, Double.MAX_VALUE) == -1); + assertTrue(Double.compare(0.0d, 1.2d) == -1); + assertTrue(Double.compare(0.0d, 0.0d) == 0); + assertTrue(Double.compare(0.0d, -0.0d) == +1); + assertTrue(Double.compare(0.0d, -1.2d) == +1); + assertTrue(Double.compare(0.0d, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(0.0d, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(-0.0d, Double.NaN) == -1); + assertTrue(Double.compare(-0.0d, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(-0.0d, Double.MAX_VALUE) == -1); + assertTrue(Double.compare(-0.0d, 1.2d) == -1); + assertTrue(Double.compare(-0.0d, 0.0d) == -1); + assertTrue(Double.compare(-0.0d, -0.0d) == 0); + assertTrue(Double.compare(-0.0d, -1.2d) == +1); + assertTrue(Double.compare(-0.0d, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(-0.0d, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(-1.2d, Double.NaN) == -1); + assertTrue(Double.compare(-1.2d, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(-1.2d, Double.MAX_VALUE) == -1); + assertTrue(Double.compare(-1.2d, 1.2d) == -1); + assertTrue(Double.compare(-1.2d, 0.0d) == -1); + assertTrue(Double.compare(-1.2d, -0.0d) == -1); + assertTrue(Double.compare(-1.2d, -1.2d) == 0); + assertTrue(Double.compare(-1.2d, -Double.MAX_VALUE) == +1); + assertTrue(Double.compare(-1.2d, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(-Double.MAX_VALUE, Double.NaN) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, Double.MAX_VALUE) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, 1.2d) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, 0.0d) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, -0.0d) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, -1.2d) == -1); + assertTrue(Double.compare(-Double.MAX_VALUE, -Double.MAX_VALUE) == 0); + assertTrue(Double.compare(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY) == +1); + + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.NaN) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.MAX_VALUE) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, 1.2d) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, 0.0d) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, -0.0d) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, -1.2d) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, -Double.MAX_VALUE) == -1); + assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY) == 0); } public void testCompareFloat() { - assertTrue(NumberUtils.compare(Float.NaN, Float.NaN) == 0); - assertTrue(NumberUtils.compare(Float.NaN, Float.POSITIVE_INFINITY) == +1); - assertTrue(NumberUtils.compare(Float.NaN, Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Float.NaN, 1.2f) == +1); - assertTrue(NumberUtils.compare(Float.NaN, 0.0f) == +1); - assertTrue(NumberUtils.compare(Float.NaN, -0.0f) == +1); - assertTrue(NumberUtils.compare(Float.NaN, -1.2f) == +1); - assertTrue(NumberUtils.compare(Float.NaN, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Float.NaN, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, Float.NaN) == -1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY) == 0); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, 1.2f) == +1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, 0.0f) == +1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, -0.0f) == +1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, -1.2f) == +1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(Float.MAX_VALUE, Float.NaN) == -1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, Float.MAX_VALUE) == 0); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, 1.2f) == +1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, 0.0f) == +1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, -0.0f) == +1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, -1.2f) == +1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(Float.MAX_VALUE, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(1.2f, Float.NaN) == -1); - assertTrue(NumberUtils.compare(1.2f, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(1.2f, Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(1.2f, 1.2f) == 0); - assertTrue(NumberUtils.compare(1.2f, 0.0f) == +1); - assertTrue(NumberUtils.compare(1.2f, -0.0f) == +1); - assertTrue(NumberUtils.compare(1.2f, -1.2f) == +1); - assertTrue(NumberUtils.compare(1.2f, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(1.2f, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(0.0f, Float.NaN) == -1); - assertTrue(NumberUtils.compare(0.0f, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(0.0f, Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(0.0f, 1.2f) == -1); - assertTrue(NumberUtils.compare(0.0f, 0.0f) == 0); - assertTrue(NumberUtils.compare(0.0f, -0.0f) == +1); - assertTrue(NumberUtils.compare(0.0f, -1.2f) == +1); - assertTrue(NumberUtils.compare(0.0f, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(0.0f, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(-0.0f, Float.NaN) == -1); - assertTrue(NumberUtils.compare(-0.0f, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(-0.0f, Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(-0.0f, 1.2f) == -1); - assertTrue(NumberUtils.compare(-0.0f, 0.0f) == -1); - assertTrue(NumberUtils.compare(-0.0f, -0.0f) == 0); - assertTrue(NumberUtils.compare(-0.0f, -1.2f) == +1); - assertTrue(NumberUtils.compare(-0.0f, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(-0.0f, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(-1.2f, Float.NaN) == -1); - assertTrue(NumberUtils.compare(-1.2f, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(-1.2f, Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(-1.2f, 1.2f) == -1); - assertTrue(NumberUtils.compare(-1.2f, 0.0f) == -1); - assertTrue(NumberUtils.compare(-1.2f, -0.0f) == -1); - assertTrue(NumberUtils.compare(-1.2f, -1.2f) == 0); - assertTrue(NumberUtils.compare(-1.2f, -Float.MAX_VALUE) == +1); - assertTrue(NumberUtils.compare(-1.2f, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, Float.NaN) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, 1.2f) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, 0.0f) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, -0.0f) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, -1.2f) == -1); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, -Float.MAX_VALUE) == 0); - assertTrue(NumberUtils.compare(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY) == +1); - - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, Float.NaN) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, 1.2f) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, 0.0f) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, -0.0f) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, -1.2f) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, -Float.MAX_VALUE) == -1); - assertTrue(NumberUtils.compare(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY) == 0); + assertTrue(Float.compare(Float.NaN, Float.NaN) == 0); + assertTrue(Float.compare(Float.NaN, Float.POSITIVE_INFINITY) == +1); + assertTrue(Float.compare(Float.NaN, Float.MAX_VALUE) == +1); + assertTrue(Float.compare(Float.NaN, 1.2f) == +1); + assertTrue(Float.compare(Float.NaN, 0.0f) == +1); + assertTrue(Float.compare(Float.NaN, -0.0f) == +1); + assertTrue(Float.compare(Float.NaN, -1.2f) == +1); + assertTrue(Float.compare(Float.NaN, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(Float.NaN, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.NaN) == -1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY) == 0); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.MAX_VALUE) == +1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, 1.2f) == +1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, 0.0f) == +1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, -0.0f) == +1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, -1.2f) == +1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(Float.MAX_VALUE, Float.NaN) == -1); + assertTrue(Float.compare(Float.MAX_VALUE, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(Float.MAX_VALUE, Float.MAX_VALUE) == 0); + assertTrue(Float.compare(Float.MAX_VALUE, 1.2f) == +1); + assertTrue(Float.compare(Float.MAX_VALUE, 0.0f) == +1); + assertTrue(Float.compare(Float.MAX_VALUE, -0.0f) == +1); + assertTrue(Float.compare(Float.MAX_VALUE, -1.2f) == +1); + assertTrue(Float.compare(Float.MAX_VALUE, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(Float.MAX_VALUE, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(1.2f, Float.NaN) == -1); + assertTrue(Float.compare(1.2f, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(1.2f, Float.MAX_VALUE) == -1); + assertTrue(Float.compare(1.2f, 1.2f) == 0); + assertTrue(Float.compare(1.2f, 0.0f) == +1); + assertTrue(Float.compare(1.2f, -0.0f) == +1); + assertTrue(Float.compare(1.2f, -1.2f) == +1); + assertTrue(Float.compare(1.2f, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(1.2f, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(0.0f, Float.NaN) == -1); + assertTrue(Float.compare(0.0f, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(0.0f, Float.MAX_VALUE) == -1); + assertTrue(Float.compare(0.0f, 1.2f) == -1); + assertTrue(Float.compare(0.0f, 0.0f) == 0); + assertTrue(Float.compare(0.0f, -0.0f) == +1); + assertTrue(Float.compare(0.0f, -1.2f) == +1); + assertTrue(Float.compare(0.0f, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(0.0f, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(-0.0f, Float.NaN) == -1); + assertTrue(Float.compare(-0.0f, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(-0.0f, Float.MAX_VALUE) == -1); + assertTrue(Float.compare(-0.0f, 1.2f) == -1); + assertTrue(Float.compare(-0.0f, 0.0f) == -1); + assertTrue(Float.compare(-0.0f, -0.0f) == 0); + assertTrue(Float.compare(-0.0f, -1.2f) == +1); + assertTrue(Float.compare(-0.0f, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(-0.0f, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(-1.2f, Float.NaN) == -1); + assertTrue(Float.compare(-1.2f, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(-1.2f, Float.MAX_VALUE) == -1); + assertTrue(Float.compare(-1.2f, 1.2f) == -1); + assertTrue(Float.compare(-1.2f, 0.0f) == -1); + assertTrue(Float.compare(-1.2f, -0.0f) == -1); + assertTrue(Float.compare(-1.2f, -1.2f) == 0); + assertTrue(Float.compare(-1.2f, -Float.MAX_VALUE) == +1); + assertTrue(Float.compare(-1.2f, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(-Float.MAX_VALUE, Float.NaN) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, Float.MAX_VALUE) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, 1.2f) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, 0.0f) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, -0.0f) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, -1.2f) == -1); + assertTrue(Float.compare(-Float.MAX_VALUE, -Float.MAX_VALUE) == 0); + assertTrue(Float.compare(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY) == +1); + + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.NaN) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.MAX_VALUE) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, 1.2f) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, 0.0f) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, -0.0f) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, -1.2f) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, -Float.MAX_VALUE) == -1); + assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY) == 0); } public void testIsDigits() {