If you have only five different values, you can easily run the test by packing the bits into short or int and checking if it is any of the answers to zero or one bit. The only invalid numbers you could get would be.
0x 0000 0000
0x 0000 0001
0x 0000 0010
0x 0000 0100
0x 0000 1000
0x 0001 0000
This gives you six values ββfor the search, puts them in the search table, and if it is not there, you have your answer.
This gives you a simple answer.
public static boolean moreThan1BitSet (int b)
{
final short multiBitLookup [] = {
1, 1, 1, 0, 1, 0, 0, 0,
1,0,0,0,0,0,0,0,0,0
0, 0, 0, 0, 0, 0, 0, 0, 0,
1,0,0,0,0,0,0,0,0,0
0, 0, 0, 0, 0, 0, 0, 0
};
if (multiBitLookup [b] == 1)
return false;
return true;
}
It does not scale long to 8 bits, but you only have five.