Java Utililty Methods BigInteger Value Check

List of utility methods to do BigInteger Value Check

Description

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

Method

booleanisBigger(final BigInteger big1, final BigInteger big2)
Returns whether the first BigInteger is bigger than the second.
final int compared = big1.compareTo(big2);
if (compared > 0) {
    return true;
return false;
booleanisCovers(BigInteger covers, BigInteger value)
is Covers
return covers.compareTo(value) > -1;
booleanisDefined(BigInteger no)
Checking if the BigInteger is set.
return no != null;
booleanisElementOfZn(BigInteger element, BigInteger n)
is Element Of Zn
return (element.compareTo(BigInteger.ZERO) != -1) && (element.compareTo(n) == -1);
booleanisEven(BigInteger x)
is Even
return !isOdd(x);
booleanisFermatNumber(BigInteger f)
Method to check if a given number is a Fermat number.
if (f.signum() <= 0)
    return false;
byte bytes[] = f.toByteArray();
int bLength = bytes.length - 1;
if (bLength == 0) {
    switch (bytes[0]) {
    case 3:
    case 5:
...
booleanisGoodGaAndGb(BigInteger g_a, BigInteger p)
is Good Ga And Gb
return !(g_a.compareTo(BigInteger.valueOf(1)) != 1
        || g_a.compareTo(p.subtract(BigInteger.valueOf(1))) != -1);
booleanisIn20PercentRange(BigInteger first, BigInteger second)
is In Percent Range
BigInteger five = BigInteger.valueOf(5);
BigInteger limit = first.add(first.divide(five));
return !isMoreThan(second, limit);
booleanisInRange(BigInteger in, int range, double eps)
Tests whether a given BigInteger is in the following range: [-2^range, 2^(eps * range)-1] (inclusive).
if (((in.signum() > 0) && (in.bitLength() > (int) (eps * range))
        && (in.compareTo(BigInteger.valueOf(1).shiftLeft(range)) > 0))
        || ((in.signum() < 0) && (in.bitLength() > range)
                && (in.compareTo(BigInteger.valueOf(-1).shiftLeft(range)) < 0)))
    return false;
return true;
booleanisInt(final BigInteger i)
is Int
return i.compareTo(MIN_INT) >= 0 && i.compareTo(MAX_INT) <= 0;