Let's say memory is precious, and I have a class with a uint32_t
member variable ui
and I know that the values will stay below 1 million. The class also hase some bool
members.
Does it make sense to use the highest (highest 2,3,..) bit(s) of
ui
in order to save memory, sincebool
is 1 byte?If it does make sense, what is the most efficient way to get the highest (leftmost?) bit (or 2nd)? I read a few old threads and there seems to be disagreement about using inline ASM or some sort of shift.