public class BitHelper
{
const int LongOne =0x1;
public static bool[] GetBitArray(int exp)
{
int length=(int)Math.Ceiling(Math.Log(exp,2));
bool[] result=new bool[length];
int i;
for(i=0;i<length;i++)
{
result[i]=(exp & (LongOne<<i))>0;
}
return result;
}
public static int GetValue(bool[] items)
{
int result=0;
int i;
for(i=0;i<items.Length;i++)
{
if(items[i])
{
result=result+(LongOne<<i);
}
}