Android Int Bit Set decode(int bits)

Here you can find the source of decode(int bits)

Description

decode

License

Open Source License

Declaration

public static Integer[] decode(int bits) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static Integer[] decode(int bits) {
        int count = 0;
        Integer[] buff = new Integer[32];
        for (int i = 0; i < buff.length; i++) {
            if ((bits & (1 << i)) > 0) {
                buff[count++] = i;//from  ww  w  .  jav  a 2s .  co m
            }
        }

        Integer[] result = new Integer[count];
        System.arraycopy(buff, 0, result, 0, count);
        return result;
    }
}

Related

  1. isBitSet(int b, int bit)
  2. isBitSet(int number, int count)
  3. isPowerOfTwo(int v)
  4. clearBit(int number, int count)
  5. contains(int bit, int... options)
  6. nextHighestPowerOfTwo(int v)
  7. toggleBit(int number, int count)