Java BigInteger From ToBigInteger(BitSet bs)

Here you can find the source of ToBigInteger(BitSet bs)

Description

Convert a bitset to a BigInteger.

License

Open Source License

Parameter

Parameter Description
bs The bitset.

Return

the corresponding BigInteger.

Declaration

public static BigInteger ToBigInteger(BitSet bs) 

Method Source Code


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

import java.util.*;
import java.math.*;

public class Main {
    /**/*from  ww w.j a  va2s  . c o  m*/
     * Convert a bitset to a BigInteger.
     * 
     * @param bs The bitset.
     * 
     * @return the corresponding BigInteger.
     */
    public static BigInteger ToBigInteger(BitSet bs) {

        BigInteger value = BigInteger.ZERO;
        for (int i = 0; i < bs.length(); i += 1) {
            if (bs.get(i))
                value = value.setBit(i);
        }
        return value;
    }
}

Related

  1. getUnsignedBigInteger(byte[] data, int offset, int length)
  2. getUnsignedBigInteger(long x)
  3. string2BigInteger(String plaintext)
  4. toBigInteger(@Nullable final Boolean value, @Nullable final BigInteger defaultValue)
  5. toBigInteger(@Nullable final byte[] value)
  6. toBigIntegerFromHex(String val)