Here you can find the source of longToBitSet(long value)
Parameter | Description |
---|---|
value | a parameter |
public static BitSet longToBitSet(long value)
//package com.java2s; //License from project: Apache License import java.util.BitSet; public class Main { /**/* ww w . j av a2 s .c o m*/ * Convert a BitSet to its equivalent integer (long) value. * * @param value * @return */ public static BitSet longToBitSet(long value) { BitSet bits = new BitSet(Long.SIZE); int index = 0; while (value != 0L) { long rem = value % 2L; if (rem != 0) { bits.set(index); } ++index; value = value >>> 1; } return bits; } }