Java BigInteger Calculate retrieveBigInteger(final byte[] buf, final int offset)

Here you can find the source of retrieveBigInteger(final byte[] buf, final int offset)

Description

Get an unsigned integer (U64) from 8 bytes in a byte[] buffer.

License

Open Source License

Parameter

Parameter Description
buf The buffer from which to retrieve the value
offset from which to get the number.

Return

the signed long number (0 to 18,446,744,073,709,551,615) stored at the offset.

Declaration

public static BigInteger retrieveBigInteger(final byte[] buf, final int offset) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w . j  a  v  a  2s  . c  o  m*/
 * Copyright (c) 2014 Stephan D. Cote' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   Stephan D. Cote 
 *      - Initial API and implementation
 */

import java.math.BigInteger;

public class Main {
    /**
     * Get an unsigned integer (U64) from 8 bytes in a byte[] buffer.
     *
     * <p>Range is from 0 to over 18 quintillion. Do you <em>really</em> need a
     * number that big?
     *
     * @param buf The buffer from which to retrieve the value
     * @param offset from which to get the number.
     *
     * @return the signed long number (0 to 18,446,744,073,709,551,615) stored at
     *         the offset.
     */
    public static BigInteger retrieveBigInteger(final byte[] buf, final int offset) {
        final byte[] chunk = new byte[8];
        System.arraycopy(buf, offset, chunk, 0, 8);

        return new BigInteger(1, chunk);
    }
}

Related

  1. parseScaledNonNegativeBigInteger(String str)
  2. product(final BigInteger min, final BigInteger max)
  3. randomFromZn(BigInteger n, Random rand)
  4. removeDuplicates(final BigInteger... values)
  5. renderBigInteger(final BigInteger bint)
  6. rightshift(byte b1, BigInteger b2)
  7. saveKey(File destDir, String fileName, BigInteger modulus, BigInteger publicExponent)
  8. saveToFile(String fileName, BigInteger mod, BigInteger exp)
  9. serializeModexpNoBase(BigInteger[] modexp, boolean withResult)