diff --git a/src/java/org/apache/commons/lang/builder/CompareToBuilder.java b/src/java/org/apache/commons/lang/builder/CompareToBuilder.java index 3e710c9b4..05bb1914b 100644 --- a/src/java/org/apache/commons/lang/builder/CompareToBuilder.java +++ b/src/java/org/apache/commons/lang/builder/CompareToBuilder.java @@ -589,7 +589,7 @@ public class CompareToBuilder { if (comparison != 0) { return this; } - comparison = NumberUtils.compare(lhs, rhs); + comparison = Double.compare(lhs, rhs); return this; } @@ -610,7 +610,7 @@ public class CompareToBuilder { if (comparison != 0) { return this; } - comparison = NumberUtils.compare(lhs, rhs); + comparison = Float.compare(lhs, rhs); return this; } diff --git a/src/java/org/apache/commons/lang/math/NumberUtils.java b/src/java/org/apache/commons/lang/math/NumberUtils.java index 555c008c3..6de017c41 100644 --- a/src/java/org/apache/commons/lang/math/NumberUtils.java +++ b/src/java/org/apache/commons/lang/math/NumberUtils.java @@ -1178,131 +1178,6 @@ public class NumberUtils { return Math.max(Math.max(a, b), c); } - //----------------------------------------------------------------------- - /** - *
Compares two doubles
for order.
This method is more comprehensive than the standard Java greater - * than, less than and equals operators.
- *-1
if the first value is less than the second.+1
if the first value is greater than the second.0
if the values are equal.- * The ordering is as follows, largest to smallest: - *
-Double.MAX_VALUE
)
- * Comparing NaN
with NaN
will
- * return 0
.
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.
- *-1
if the first value is less than the second.
- * +1
if the first value is greater than the second.
- * 0
if the values are equal.
- * The ordering is as follows, largest to smallest: - *
-Float.MAX_VALUE
)
- * Comparing NaN
with NaN
will return
- * 0
.
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
diff --git a/src/java/org/apache/commons/lang/math/Range.java b/src/java/org/apache/commons/lang/math/Range.java
index dbc89b650..6eab17b87 100644
--- a/src/java/org/apache/commons/lang/math/Range.java
+++ b/src/java/org/apache/commons/lang/math/Range.java
@@ -267,8 +267,8 @@ public abstract class Range {
* 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 @@ public abstract class Range {
* 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;
}
diff --git a/src/java/org/apache/commons/lang/mutable/MutableDouble.java b/src/java/org/apache/commons/lang/mutable/MutableDouble.java
index 1522581af..cf41f63d8 100644
--- a/src/java/org/apache/commons/lang/mutable/MutableDouble.java
+++ b/src/java/org/apache/commons/lang/mutable/MutableDouble.java
@@ -303,7 +303,7 @@ public class MutableDouble extends Number implements Comparable, Mutable {
public int compareTo(Object obj) {
MutableDouble other = (MutableDouble) obj;
double anotherVal = other.value;
- return NumberUtils.compare(value, anotherVal);
+ return Double.compare(value, anotherVal);
}
/**
diff --git a/src/java/org/apache/commons/lang/mutable/MutableFloat.java b/src/java/org/apache/commons/lang/mutable/MutableFloat.java
index 7af395f0e..584de6f59 100644
--- a/src/java/org/apache/commons/lang/mutable/MutableFloat.java
+++ b/src/java/org/apache/commons/lang/mutable/MutableFloat.java
@@ -304,7 +304,7 @@ public class MutableFloat extends Number implements Comparable, Mutable {
public int compareTo(Object obj) {
MutableFloat other = (MutableFloat) obj;
float anotherVal = other.value;
- return NumberUtils.compare(value, anotherVal);
+ return Float.compare(value, anotherVal);
}
/**
diff --git a/src/test/org/apache/commons/lang/math/NumberUtilsTest.java b/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
index b7f9d08ff..2cc255342 100644
--- a/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
+++ b/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
@@ -775,188 +775,189 @@ public class NumberUtilsTest extends TestCase {
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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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.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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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.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() {