List of utility methods to do BigInteger Value Check
boolean | isPowerOfTwo(BigInteger bintValue) is Power Of Two int bitIndex = bintValue.getLowestSetBit(); if (bitIndex < 0) { return false; return bintValue.clearBit(bitIndex).equals(BigInteger.ZERO); |
boolean | isPowerOfTwo(BigInteger x) is Power Of Two return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
|
boolean | isRootInQuadraticResidues(BigInteger n, BigInteger p) is Root In Quadratic Residues BigInteger tow = BigInteger.valueOf(2); BigInteger x = n.mod(p); if (p.equals(tow)) { return x.mod(tow).equals(BigInteger.ONE); BigInteger exponent = p.subtract(BigInteger.ONE).divide(tow); return x.modPow(exponent, p).equals(BigInteger.ONE); |
boolean | isSqrtXXX(BigInteger n, BigInteger root) is Sqrt XXX final BigInteger lowerBound = root.pow(2); final BigInteger upperBound = root.add(BigInteger.ONE).pow(2); return lowerBound.compareTo(n) <= 0 && n.compareTo(upperBound) < 0; |
boolean | isZero(BigInteger value) is Zero return value.compareTo(BigInteger.ZERO) == 0;
|