Java Utililty Methods BigDecimal Compare

List of utility methods to do BigDecimal Compare

Description

The list of methods to do BigDecimal Compare are organized into topic(s).

Method

Integercompare(BigDecimal decimal, Integer i)
compare
if (decimal != null && i != null) {
    return decimal.compareTo(new BigDecimal(i));
return null;
intcompare(BigDecimal first, BigDecimal second)
compare
if (areEqual(first, second)) {
    return 0;
return first.compareTo(second);
intcompare(BigDecimal one, BigDecimal other)
Vergelijkt 2 BigDecimals (nullsafe).
if (one == null && other == null)
    return 0;
if (one == null)
    return -1;
else if (other == null)
    return 1;
return one.compareTo(other);
intcompare(BigDecimal v1, BigDecimal v2)
compare
int intValue = 0;
Double d1 = v1.doubleValue();
Double d2 = v2.doubleValue();
if (d1 > d2) {
    intValue = 1;
if (d1 == d2) {
    intValue = 0;
...
intcompareBigDecimal(BigDecimal bigDecimal, BigDecimal bigDecimal2, boolean desc)
compare Big Decimal
int v = bigDecimal.compareTo(bigDecimal2);
if (v < 0)
    return lessThan(desc);
else if (v > 0)
    return moreThan(desc);
else
    return 0;
booleancompareBigDecimals(java.math.BigDecimal one, java.math.BigDecimal two)
Compare two BigDecimals.
if (one.scale() != two.scale()) {
    double doubleOne = (one).doubleValue();
    double doubleTwo = (two).doubleValue();
    if ((doubleOne != Double.POSITIVE_INFINITY) && (doubleOne != Double.NEGATIVE_INFINITY)
            && (doubleTwo != Double.POSITIVE_INFINITY) && (doubleTwo != Double.NEGATIVE_INFINITY)) {
        return doubleOne == doubleTwo;
return one.equals(two);
intcompareTo(BigDecimal b1, BigDecimal b2)
Compare to b1 with b2
if (b1 == null && b2 == null) {
    return 0;
if (b1 == null) {
    b1 = ZERO;
if (b2 == null) {
    b2 = ZERO;
...
intcompareTo(final BigDecimal b0, final BigDecimal b1)
Null safe compareTo of two BigDecimal s.
if (b0 == b1) {
    return 0;
} else if (b0 == null) {
    return 1;
} else if (b1 == null) {
    return -1;
} else {
    return b0.compareTo(b1);
...
intcompareTo(final BigDecimal v1, final BigDecimal v2)
compare To
int ret = 1;
if (v1 != null && v2 != null) {
    ret = v1.compareTo(v2);
} else if (v1 == null && v2 == null) {
    ret = 0;
} else if (v1 == null) {
    ret = -1;
return ret;
intcompareToOne(BigDecimal x)
compare To One
return x.compareTo(BigDecimal.ONE);