Java Utililty Methods BigInteger Create

List of utility methods to do BigInteger Create

Description

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

Method

BigIntegertoBigInteger(final byte[] buffer, final int offset, final int length)
to Big Integer
return new BigInteger(Arrays.copyOfRange(buffer, offset, offset + length));
BigIntegertoBigInteger(final byte[] bytes)
Converts a little endian byte array to a BigInteger.
final byte[] bigEndianBytes = new byte[bytes.length + 1];
for (int i = 0; i < bytes.length; ++i) {
    bigEndianBytes[i + 1] = bytes[bytes.length - i - 1];
return new BigInteger(bigEndianBytes);
BigIntegertoBigInteger(final Integer i)
Null save convert of a Integer to a BigInteger .
if (i != null) {
    return BigInteger.valueOf(i);
} else {
    return null;
BigIntegertoBigInteger(int arg)
to Big Integer
return new BigInteger(Integer.toString(arg));
BigIntegertoBigInteger(int[] x, int bitsPerDigit)
to Big Integer
final int digitsPerLong = (59 / bitsPerDigit) + 1;
BigInteger c = BigInteger.ZERO;
for (int i = 0; i < x.length;) {
    long a = 0;
    for (int j = 0; i < x.length && j < digitsPerLong; j++) {
        a |= ((long) x[i] << (bitsPerDigit * j));
        i++;
    c = c.add(BigInteger.valueOf(a).shiftLeft(bitsPerDigit * digitsPerLong * ((i - 1) / digitsPerLong)));
return c;
ListtoBigInteger(List integerVector)
to Big Integer
List<BigInteger> bigIntegerVector = null;
if (integerVector != null) {
    bigIntegerVector = new ArrayList<BigInteger>();
    for (Integer i : integerVector) {
        bigIntegerVector.add(BigInteger.valueOf(i));
return bigIntegerVector;
...
BigIntegertoBigInteger(long value)
to Big Integer
return new BigInteger(String.valueOf(value));
BigIntegertoBigInteger(Object o)
to Big Integer
if (o instanceof Integer) {
    return BigInteger.valueOf(((Integer) o).intValue());
} else if (o instanceof BigInteger) {
    return (BigInteger) o;
} else if (o instanceof Double) {
    return null;
} else {
    throw new IllegalArgumentException();
...
BigIntegertoBigInteger(Object value)
Convert an Object to a BigInteger.
if (value == null)
    return null;
if (value instanceof BigInteger)
    return (BigInteger) value;
if (value instanceof String) {
    if ("".equals((String) value))
        return null;
    return new BigInteger((String) value);
...
BigIntegertoBigInteger(UUID uuid)
to Big Integer
return new BigInteger(1, toByteArray(uuid));