Java BigInteger Format formatBigIntegerBinary(final long value, byte[] buf, final int offset, final int length, final boolean negative)

Here you can find the source of formatBigIntegerBinary(final long value, byte[] buf, final int offset, final int length, final boolean negative)

Description

format Big Integer Binary

License

Apache License

Declaration

private static void formatBigIntegerBinary(final long value, byte[] buf, final int offset, final int length,
            final boolean negative) 

Method Source Code

//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*/
        }
    }
}

Related

  1. formatBigInteger(BigInteger bi, int length)
  2. formatSerialNumber(BigInteger bi)
  3. formatSerialNumber(final BigInteger serial)
  4. formatSize(BigInteger size)
  5. formatTime(BigInteger femto)