Java BitSet unpackInt(BitSet bs, int offset, int noOfBits)

Here you can find the source of unpackInt(BitSet bs, int offset, int noOfBits)

Description

Unpack an integer value from a bit set.

License

Open Source License

Parameter

Parameter Description
bs The bit set to unpack the integer value from
offset The offset in the bit set for the integer value
noOfBits Number of bits used for unpacking

Return

The unpacked integer value

Declaration

public static int unpackInt(BitSet bs, int offset, int noOfBits) 

Method Source Code

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

import java.util.BitSet;

public class Main {
    /**/* w  w w.ja v a 2  s  .c o  m*/
     * Unpack an integer value from a bit set.
     *
     * @param bs       The bit set to unpack the integer value from
     * @param offset   The offset in the bit set for the integer value
     * @param noOfBits Number of bits used for unpacking
     * @return The unpacked integer value
     */
    public static int unpackInt(BitSet bs, int offset, int noOfBits) {
        int val = 0;
        for (int i = 0; i < noOfBits; i++) {
            if (bs.get(offset + i))
                val |= 1 << (noOfBits - i - 1);
        }
        return val;
    }
}

Related

  1. toInteger(final BitSet bits)
  2. toLong(final BitSet value)
  3. toString(BitSet bs)
  4. translateBitSetToProjIndx(BitSet projBitSet)
  5. unionAdd(BitSet newClique, int nNodes, LinkedList cliques)
  6. unsignedIntToLittleEndianBitSet(int i)
  7. validateEncoded(BitSet encoded, int encodedBitLength)
  8. validCookieNameOctets(BitSet validCookieValueOctets)