Java examples for java.util:BitSet
Convert a bitset to an int.
//package com.java2s; import java.util.*; public class Main { /**/*from www. j a v a 2s.c om*/ * Convert a bitset to an int. * * @param bs The bitset. * * @return the corresponding int. */ public static int ToInt(BitSet bs) { int pow = 1; int value = 0; for (int i = 0; i < bs.length(); i += 1) { if (bs.get(i)) value += pow; pow *= 2; } return value; } }