You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/04/30 08:03:17 UTC
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/
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 @@
//-----------------------------------------------------------------------
/**
- * <p>Compares two <code>doubles</code> for order.</p>
- *
- * <p>This method is more comprehensive than the standard Java greater
- * than, less than and equals operators.</p>
- * <ul>
- * <li>It returns <code>-1</code> if the first value is less than the second.</li>
- * <li>It returns <code>+1</code> if the first value is greater than the second.</li>
- * <li>It returns <code>0</code> if the values are equal.</li>
- * </ul>
- *
- * <p>
- * The ordering is as follows, largest to smallest:
- * <ul>
- * <li>NaN
- * <li>Positive infinity
- * <li>Maximum double
- * <li>Normal positive numbers
- * <li>+0.0
- * <li>-0.0
- * <li>Normal negative numbers
- * <li>Minimum double (<code>-Double.MAX_VALUE</code>)
- * <li>Negative infinity
- * </ul>
- * </p>
- *
- * <p>Comparing <code>NaN</code> with <code>NaN</code> will
- * return <code>0</code>.</p>
- *
- * @param lhs the first <code>double</code>
- * @param rhs the second <code>double</code>
- * @return <code>-1</code> if lhs is less, <code>+1</code> if greater,
- * <code>0</code> 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;
- }
- }
-
- /**
- * <p>Compares two floats for order.</p>
- *
- * <p>This method is more comprehensive than the standard Java greater than,
- * less than and equals operators.</p>
- * <ul>
- * <li>It returns <code>-1</code> if the first value is less than the second.
- * <li>It returns <code>+1</code> if the first value is greater than the second.
- * <li>It returns <code>0</code> if the values are equal.
- * </ul>
- *
- * <p> The ordering is as follows, largest to smallest:
- * <ul>
- * <li>NaN
- * <li>Positive infinity
- * <li>Maximum float
- * <li>Normal positive numbers
- * <li>+0.0
- * <li>-0.0
- * <li>Normal negative numbers
- * <li>Minimum float (<code>-Float.MAX_VALUE</code>)
- * <li>Negative infinity
- * </ul>
- *
- * <p>Comparing <code>NaN</code> with <code>NaN</code> will return
- * <code>0</code>.</p>
- *
- * @param lhs the first <code>float</code>
- * @param rhs the second <code>float</code>
- * @return <code>-1</code> if lhs is less, <code>+1</code> if greater,
- * <code>0</code> 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;
- }
- }
-
- //-----------------------------------------------------------------------
- /**
* <p>Checks whether the <code>String</code> contains only
* digit characters.</p>
*
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 <code>double</code> 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 <code>float</code> 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() {