Java BigInteger From getUnsignedBigInteger(byte[] data, int offset, int length)

Here you can find the source of getUnsignedBigInteger(byte[] data, int offset, int length)

Description

Returns a positive BigInteger from the given bytes.

License

Open Source License

Parameter

Parameter Description
data The bytes.
offset The first byte.
length The amount of bytes to process.

Return

A BigInteger from the given bytes.

Declaration

public static BigInteger getUnsignedBigInteger(byte[] data, int offset, int length) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    /**// www  .j  ava2s .  c  o  m
     * Returns a positive BigInteger from the given bytes. (Big endian)
     * 
     * @param data
     *            The bytes.
     * @param offset
     *            The first byte.
     * @param length
     *            The amount of bytes to process.
     * @return A BigInteger from the given bytes.
     */
    public static BigInteger getUnsignedBigInteger(byte[] data, int offset, int length) {
        if (length == 0) {
            return BigInteger.ZERO;
        }

        byte[] value = new byte[length + 1];
        System.arraycopy(data, offset, value, 1, length);

        return new BigInteger(value);
    }
}

Related

  1. bytesToBigInteger(byte[] buffer)
  2. bytesToBigInteger(byte[] data)
  3. bytesToBigInteger(byte[] data, int[] offset)
  4. convertToBigInteger(String s)
  5. convertToBigInteger(String sequence)
  6. getUnsignedBigInteger(long x)
  7. string2BigInteger(String plaintext)
  8. toBigInteger(@Nullable final Boolean value, @Nullable final BigInteger defaultValue)
  9. toBigInteger(@Nullable final byte[] value)