Java BigInteger Calculate encode_long(BigInteger big)

Here you can find the source of encode_long(BigInteger big)

Description

encode an arbitrary long number into a byte array (little endian).

License

Open Source License

Declaration

public static byte[] encode_long(BigInteger big) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    /**//from w w w  .j av  a  2 s .  co m
     * encode an arbitrary long number into a byte array (little endian).
     */
    public static byte[] encode_long(BigInteger big) {
        byte[] data = big.toByteArray();
        // reverse the byte array because pickle uses little endian
        byte[] data2 = new byte[data.length];
        for (int i = 0; i < data.length; ++i)
            data2[data.length - i - 1] = data[i];
        return data2;
    }
}

Related

  1. dumpBitLengthOfValues(BigInteger... data)
  2. dumpDataPathId(BigInteger datapathId)
  3. dumpNumber(PrintStream out, String s, BigInteger bi)
  4. emit(BigInteger integer)
  5. encode(BigInteger number, String alphabets)
  6. encodeBigInt(OutputStream out, BigInteger x)
  7. encodeBigIntNoTypeCode(BigInteger value)
  8. encodeCompactBits(BigInteger value)
  9. encodeFloat(BigInteger j, int e)