Here you can find the source of formatBigIntegerBinary(final long value, byte[] buf, final int offset, final int length, final boolean negative)
private static void formatBigIntegerBinary(final long value, byte[] buf, 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 void formatBigIntegerBinary(final long value, byte[] buf, final int offset, final int length, final boolean negative) { BigInteger val = BigInteger.valueOf(value); final byte[] b = val.toByteArray(); final int len = b.length; final int off = offset + length - len; System.arraycopy(b, 0, buf, off, len); final byte fill = (byte) (negative ? 0xff : 0); for (int i = offset + 1; i < off; i++) { buf[i] = fill;/*w w w. j a v a 2s . c o m*/ } } }