Java BigInteger Calculate base128(BigInteger val)

Here you can find the source of base128(BigInteger val)

Description

Convert to base 128 (bigendian), using shifts.

License

Open Source License

Parameter

Parameter Description
val a parameter

Declaration

public static ArrayList<Integer> base128(BigInteger val) 

Method Source Code

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

import java.math.BigInteger;
import java.util.ArrayList;

public class Main {
    public final static BigInteger BN127 = new BigInteger("127");

    /**/*from  w w  w . j  a  v  a 2s.  c o  m*/
     * Convert to base 128 (bigendian), using shifts.
     * @param val
     * @return
     */
    public static ArrayList<Integer> base128(BigInteger val) {
        ArrayList<Integer> result = new ArrayList<Integer>();
        int part = val.and(BN127).intValue();
        val = val.shiftRight(7);
        result.add(0, new Integer(part));
        while (!val.equals(BigInteger.ZERO)) {
            part = val.and(BN127).intValue();
            val = val.shiftRight(7);
            part += 128;
            result.add(0, new Integer(part));
        }
        ;
        return result;
    }
}

Related

  1. areEqual(BigInteger[] a, BigInteger[] b)
  2. base62Encode(BigInteger number)
  3. bitArrayToUnsignedBigInteger(int[] bits)
  4. bitcoinValueToFriendlyString(BigInteger value)
  5. byte_size(BigInteger bi)