Here you can find the source of bitSetToUnsignedInt(BitSet b, int startBit, int length)
Parameter | Description |
---|---|
b | BitSet to convert. |
startBit | LSB bit of the integer. |
length | Number of bits to read. |
public static int bitSetToUnsignedInt(BitSet b, int startBit, int length)
//package com.java2s; //License from project: Open Source License import java.util.BitSet; public class Main { /**/*from w w w .j a va 2 s. co m*/ * Convert a BitSet to an unsigned integer. * * @param b BitSet to convert. * @param startBit LSB bit of the integer. * @param length Number of bits to read. * @return an unsigned integer number. */ public static int bitSetToUnsignedInt(BitSet b, int startBit, int length) { int val = 0; int bitval = 1; for (int i = 0; i < length; i++) { if (b.get(startBit + i)) val += bitval; bitval += bitval; } return val; } }