Java Utililty Methods BigInteger Calculate

List of utility methods to do BigInteger Calculate

Description

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

Method

BigIntegergetMetaDataMaskForLPortDispatcher(BigInteger metadataMaskForServiceIndex, BigInteger metadataMaskForLPortTag, BigInteger metadataMaskForService)
get Meta Data Mask For L Port Dispatcher
return metadataMaskForServiceIndex.or(metadataMaskForLPortTag).or(metadataMaskForService);
BigIntegergetN(BigInteger p, BigInteger q)
get N
return p.multiply(q);
intgetNafWeight(BigInteger k)
get Naf Weight
if (k.signum() == 0) {
    return 0;
BigInteger _3k = k.shiftLeft(1).add(k);
BigInteger diff = _3k.xor(k);
return diff.bitCount();
longgetNatRouterIdFromMetadata(BigInteger metadata)
get Nat Router Id From Metadata
return (metadata.and(METADATA_MASK_VRFID)).longValue();
BigIntegergetNetAddress(BigInteger ip, BigInteger netmask)
Gets the net address.
return ip.and(netmask).and(BITMASK_IPV6);
BigIntegergetNextLexicographicalPermutation(BigInteger v)
It computes lexicographically the next permutation of the bits in the given number.
BigInteger t = v.or(v.subtract(BigInteger.ONE)).add(BigInteger.ONE);
return t.and(t.negate()).divide(v.and(v.negate())).shiftRight(1).subtract(BigInteger.ONE).or(t);
BigIntegergetNRightmostBits(final BigInteger in, final int n)
Returns a BigInteger with the n rightmost bits of in.
final BigInteger mask = BigInteger.valueOf(2).pow(n).subtract(BigInteger.ONE);
return in.and(mask);
ListgetNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)
This method generates all integer numbers between the given range
List<BigInteger> numbers;
if (maxValue.longValue() > Integer.MAX_VALUE) {
    numbers = new LinkedList<>();
} else {
    numbers = new ArrayList<>();
BigInteger auxiliarNumber = minValue;
for (; auxiliarNumber.compareTo(maxValue) < 1; auxiliarNumber = auxiliarNumber.add(BigInteger.ONE)) {
...
BigIntegergetPrivateKey(BigInteger ran, BigInteger publicKey)
get Private Key
return publicKey.modInverse(ran);
byte[]getPrivateKeyBytes(BigInteger privateKey)
get Private Key Bytes
byte[] privateKeyPlainNumber = privateKey.toByteArray();
int plainNumbersOffs = privateKeyPlainNumber[0] == 0 ? 1 : 0;
byte[] privateKeyBytes = new byte[32];
System.arraycopy(privateKeyPlainNumber, plainNumbersOffs, privateKeyBytes,
        privateKeyBytes.length - (privateKeyPlainNumber.length - plainNumbersOffs),
        privateKeyPlainNumber.length - plainNumbersOffs);
return privateKeyBytes;