Java Utililty Methods BigDecimal Value Check

List of utility methods to do BigDecimal Value Check

Description

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

Method

booleanisPositive(BigDecimal number)
is Positive
return number.signum() == 1;
BooleanisPositive(BigDecimal value)
is Positive
return value != null && value.compareTo(BigDecimal.ZERO) > 0;
booleanisPrimeNumber(BigDecimal inBd)
is Prime Number
if (inBd == null || isNotZero(inBd.remainder(BigDecimal.ONE))) {
    return false;
return isPrimeNumber(inBd.toBigInteger());
booleanisProfitable(BigDecimal ask, BigDecimal bid, BigDecimal fee, BigDecimal minProfit)
Returns if a combined bid/ask operation is profitable for the specified fees and desired profit
BigDecimal profit = getProfit(ask, bid, fee);
boolean result = profit.compareTo(minProfit) >= 0;
return result;
booleanisSameValue(final BigDecimal val1, final BigDecimal val2)
is Same Value
return val1 == null && val2 == null || val1 != null && val2 != null && val1.compareTo(val2) == 0;
booleanisStrictementNegatif(BigDecimal pNombre)
is Strictement Negatif
return null != pNombre && 0 < ZERO.compareTo(pNombre);
booleanisUnscaledValueEqualsOriginal(BigDecimal bigDecimal, BigInteger bigInteger)
is Unscaled Value Equals Original
return bigDecimal.equals(new BigDecimal(bigInteger));
booleanisValidDecimal(BigDecimal bd)
is Valid Decimal
BigInteger usv = bd.unscaledValue();
long usvl = usv.longValue();
return usv.equals(BigInteger.valueOf(usvl));
booleanisValidLongitude(BigDecimal value)
is Valid Longitude
BigDecimal min = new BigDecimal("31.2");
BigDecimal max = new BigDecimal("38.9");
return value != null && value.compareTo(min) >= 0 && value.compareTo(max) <= 0;
booleanisValueEquals(BigDecimal decimal1, BigDecimal decimal2)
e.g.
if (decimal1 == null && decimal2 == null)
    return true;
if (decimal1 == null && decimal2 != null)
    return false;
if (decimal1 != null && decimal2 == null)
    return false;
return cutInvalidSacle(decimal1).equals(cutInvalidSacle(decimal2));