I have numbers lower than 16 and I want to store them the smallest way possible. I currently convert my integer to a byte but I don't need the whole byte. I think I only need 4 bits to hold my number. I want to use as little of a byte as I can.
byte solutionLength = (byte) myArray.length;
return solutionLength;
myArray.length
is always less than 12.
How can I use as few bits to store to my variable solutionLength
?