Java examples for java.util:BitSet
Convert a bitset to a long.
//package com.java2s; import java.util.*; public class Main { /**/*from w w w.jav a2 s . c o m*/ * Convert a bitset to a long. * * @param bs The bitset. * * @return the corresponding long. */ public static long ToLong(BitSet bs) { long pow = 1; long value = 0; for (int i = 0; i < bs.length(); i += 1) { if (bs.get(i)) value += pow; pow *= 2; } return value; } }