***Background Information
A byte is 8 bits.
Bool is 1 byte.
Char is 1 byte.
Int is 4 bytes (therefore: 32 bits)
***What I want..
I've been programming for quite a while.
As many know, less bytes = better performance.
Many replace 'int' with 'char' when doing small tasks. Like, how many hours are in a day. You don't need the range of 0 - ~32000 (int), 0-255 (char) is sufficient.
However, I want to have true BOOLEAN, instead of 0-255 possible bool.
***How would I do this?
In C, or any language (if there is one)..
I'd like to create a bit-sized variable.
Example (in text):
declare new type of 3 bits named 3bit
Then this new 3 bit variable would have
000 - 111
In base 10: 0 - 7
Then when I declare the 3 bit variable, instead of the 8 bit variable, I theoretically save 5 bits during creation, but have less bits to actually manipulate.
If there is a way, it would then be possible to create a 1 bit variable, which would be (bool), so when you do a bit-test (or a simple if statement), it will only have 1 bit to check and there would be no waste to the other 7. But I'm not looking for a response to save the speed for bool solely. I'd like the power to create a 3, 4.. 17, 11, any size bit variable. Instead of crunching 8 bits together, which is just a structure of chars combined.
Thank you, I'd love to hear this is possible. Cannot find a narrow result in searches.
Crosility