Here you can find the source of parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative)
private static long parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative)
//package com.java2s; //License from project: Apache License import java.math.BigInteger; public class Main { private static long parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative) { byte[] remainder = new byte[length - 1]; System.arraycopy(buffer, offset + 1, remainder, 0, length - 1); BigInteger val = new BigInteger(remainder); if (negative) { // 2's complement val = val.add(BigInteger.valueOf(-1)).not(); }/*from w ww . j a v a2 s. c om*/ if (val.bitLength() > 63) { throw new IllegalArgumentException("At offset " + offset + ", " + length + " byte binary number" + " exceeds maximum signed long" + " value"); } return negative ? -val.longValue() : val.longValue(); } }