I noticed while making a program that a lot of my int
type variables never went above ten. I figure that because an int
is 2 bytes at the shortest (1 if you count char
), so I should be able to store 4 unsigned ints
with a max value of 15 in a short int, and I know I can access each one individually using >>
and <<
:
short unsigned int SLWD = 11434;
S is (SLWD >> 12), L is ((SLWD << 4) >> 12),
W is ((SLWD << 8) >> 12), and D is ((SLWD << 8) >> 12)
However, I have no idea how to encompase this in a function of class, since any type of GetVal()
function would have to be of type int
, which defeats the purpose of isolating the bits in the first place.