List of utility methods to do BigInteger Value Check
boolean | isIntValue(BigInteger bi) Checks, whether a BigInteger my be converted to an integer, i.e. if (bi.compareTo(MIN_INT_BIG_INTEGER) < 0) return false; if (bi.compareTo(MAX_INT_BIG_INTEGER) > 0) return false; return true; |
boolean | isLessThan(BigInteger valueA, BigInteger valueB) is Less Than return valueA.compareTo(valueB) < 0;
|
boolean | isLong(BigInteger number) is Long long i = number.longValue(); BigInteger b = new BigInteger(String.valueOf(i)); return number.equals(b); |
boolean | isMersenneNumber(BigInteger n) Method to check if a given number is a Mersenne number (primality of the number is not checked). if (n.signum() < 0) return false; byte bytes[] = n.toByteArray(); byte b = bytes[0]; if ((b & (b + 1)) != 0) return false; for (int i = 1; i < bytes.length; i++) if (bytes[i] != -1) ... |
boolean | isNegative(BigInteger i) is Negative return i.signum() < 0;
|
boolean | isNumberInRange(String text, BigInteger min, BigInteger max) Check whether the number is in range [min, max] inclusive. BigInteger value = null; try { value = new BigInteger(text); } catch (Exception e) { return false; if (min != null) { if (value.compareTo(min) < 0) { ... |
boolean | isOdd(BigInteger in) Tests whether a given BigInteger is odd. return in.testBit(0);
|
boolean | isOdd(BigInteger x) is Odd return x.testBit(0);
|
boolean | isPerfectCubic(BigInteger n) is Perfect Cubic while (maxCubicInCache.compareTo(n) < 0) { Long v = cubicCache.get(maxCubicInCache); ++v; BigInteger vb = BigInteger.valueOf(v); BigInteger k = vb.multiply(vb).multiply(vb); cubicCache.put(k, v); maxCubicInCache = k; return cubicCache.containsKey(n); |
boolean | isPositive(final BigInteger value) Tests if a given BigInteger value is positive. if (value == null) { return false; return value.signum() == 1; |