Java BigInteger Calculate decodeBitListFromBigInteger(BigInteger bits)

Here you can find the source of decodeBitListFromBigInteger(BigInteger bits)

Description

decode Bit List From Big Integer

License

Apache License

Declaration

public static int[] decodeBitListFromBigInteger(BigInteger bits) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static int[] decodeBitListFromBigInteger(BigInteger bits) {
        List<Integer> resultList = new ArrayList<Integer>();
        BigInteger mask = BigInteger.ONE;
        int valueCandidate = 1;
        while (mask.compareTo(bits) <= 0) {
            if ((mask.and(bits)).equals(mask)) {
                resultList.add(Integer.valueOf(valueCandidate));
            }//www  . ja va2 s.co m
            valueCandidate++;
            mask = mask.shiftLeft(1);
        }

        int[] result = new int[resultList.size()];
        for (int i = 0; i < result.length; i++) {
            result[i] = resultList.get(i).intValue();
        }
        return result;
    }
}

Related

  1. copyOfRange(BigInteger[] data, int from, int to)
  2. createUnsignedBigInteger(byte[] data)
  3. createUUID(int version, String gtin, BigInteger phar)
  4. cryptRSA(byte[] data, BigInteger exponent, BigInteger modulus)
  5. decodeBigInteger(String value)
  6. decodeFloat(BigInteger rawSign, BigInteger rawExponent, BigInteger rawMantissa, int signWidth, int exponentWidth, int mantissaWidth, int bias, MathContext mc)
  7. decodeToBigInteger(String input)
  8. DiffieHellman(BigInteger p, BigInteger g, BigInteger x, BigInteger y, BigInteger y_B)
  9. distance(BigInteger a, BigInteger b)