Here you can find the source of retrieveBigInteger(final byte[] buf, final int offset)
Parameter | Description |
---|---|
buf | The buffer from which to retrieve the value |
offset | from which to get the number. |
public static BigInteger retrieveBigInteger(final byte[] buf, final int offset)
//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); } }