Java BitSet Create convertIntToBitSet(int value)

Here you can find the source of convertIntToBitSet(int value)

Description

convert Int To Bit Set

License

Apache License

Declaration

public static BitSet convertIntToBitSet(int value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.BitSet;

public class Main {
    public static BitSet convertIntToBitSet(int value) {
        BitSet bits = new BitSet();
        int index = 0;
        while (value != 0) {
            if ((value % 2) != 0) {
                bits.set(index);//from w w w .ja  va2s . c o  m
            }
            ++index;
            value = value >>> 1;
        }
        return bits;
    }
}

Related

  1. Byte2BitSet(byte bytes)
  2. byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended)
  3. byte2BitSet(byte[] b, int offset, int maxBits)
  4. convert(final long value)
  5. convert(long value, int bitSetOffset, BitSet bits)