this post was submitted on 14 Mar 2026
18 points (95.0% liked)
Learn Programming
2134 readers
26 users here now
Posting Etiquette
-
Ask the main part of your question in the title. This should be concise but informative.
-
Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.
-
Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.
-
Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
One project I worked with stored boolean values as bits in an 8-bit int, and then used binary math to read and write individual bits from that int, with each bit representing a distinct and independent boolean variable.
Really weird, complicated, and sounds kind of dumb ... but it worked, and it was extremely memory-efficient.
C++ actually does this 'optimisation' for
std::vector<bool>. I say 'optimisation' because it effectively trades time for space, which is usually the opposite of what you want - space is cheap, time usually isn't. Sometimes it's a good tradeoff though - it's common in embedded development where you might only have a few kB of RAM.Oh hey I do this in jwts too.
I need to encode a lot of permissions
Don't ask