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

BigIntegerclip(BigInteger bi, int numberOfBytes)
Used on BigIntegers known to fit into x number of bytes.
byte[] unclipped = bi.toByteArray();
if (unclipped.length <= numberOfBytes) {
    return bi;
byte[] constructionBytes = Arrays.copyOfRange(unclipped, unclipped.length - numberOfBytes,
        unclipped.length);
return new BigInteger(constructionBytes);
BigInteger[]clone(BigInteger[] data)
clone
if (data == null) {
    return null;
BigInteger[] copy = new BigInteger[data.length];
System.arraycopy(data, 0, copy, 0, data.length);
return copy;
voidcopy_into_byte_array(BigInteger bi, byte[] a)
Copy a BigInteger into a byte array.
byte[] bia = bi.toByteArray();
assert bia.length <= a.length || (bia.length == a.length + 1 && bia[0] == 0);
for (int i = 0; i < a.length - bia.length; i++)
    a[i] = 0;
System.arraycopy(bia, bia.length == a.length + 1 ? 1 : 0, a,
        bia.length == a.length + 1 ? 0 : a.length - bia.length,
        bia.length == a.length + 1 ? a.length : bia.length);
return;
...
BigInteger[]copyOf(BigInteger[] data, int newLength)
copy Of
BigInteger[] tmp = new BigInteger[newLength];
if (newLength < data.length) {
    System.arraycopy(data, 0, tmp, 0, newLength);
} else {
    System.arraycopy(data, 0, tmp, 0, data.length);
return tmp;
BigInteger[]copyOfRange(BigInteger[] data, int from, int to)
copy Of Range
int newLength = getLength(from, to);
BigInteger[] tmp = new BigInteger[newLength];
if (data.length - from < newLength) {
    System.arraycopy(data, from, tmp, 0, data.length - from);
} else {
    System.arraycopy(data, from, tmp, 0, newLength);
return tmp;
...
BigIntegercreateUnsignedBigInteger(byte[] data)
create Unsigned Big Integer
byte[] unsigned = new byte[data.length + 1];
unsigned[0] = (byte) 0x00;
System.arraycopy(data, 0, unsigned, 1, data.length);
return new BigInteger(unsigned);
StringcreateUUID(int version, String gtin, BigInteger phar)
The deterministic id of an ArtikelstammItem item.
return createUUID(version, gtin, phar, true);
byte[]cryptRSA(byte[] data, BigInteger exponent, BigInteger modulus)
crypt RSA
return new BigInteger(data).modPow(exponent, modulus).toByteArray();
BigIntegerdecodeBigInteger(String value)
decode Big Integer
int radix = 10;
int index = 0;
boolean negative = false;
if (value.startsWith("-")) {
    negative = true;
    index++;
if (value.startsWith("0x", index) || value.startsWith("0X", index)) {
...
int[]decodeBitListFromBigInteger(BigInteger bits)
decode Bit List From Big Integer
List<Integer> resultList = new ArrayList<Integer>();
BigInteger mask = BigInteger.ONE;
int valueCandidate = 1;
while (mask.compareTo(bits) <= 0) {
    if ((mask.and(bits)).equals(mask)) {
        resultList.add(Integer.valueOf(valueCandidate));
    valueCandidate++;
...