Here you can find the source of unpackInt(BitSet bs, int offset, int noOfBits)
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 |
public static int unpackInt(BitSet bs, int offset, int noOfBits)
//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; } }