Most efficient way to extract bit flags
Posted
by Hallik
on Stack Overflow
See other posts from Stack Overflow
or by Hallik
Published on 2010-05-07T21:50:16Z
Indexed on
2010/05/07
21:58 UTC
Read the original article
Hit count: 367
I have these possible bit flags.
1, 2, 4, 8, 16, 64, 128, 256, 512, 2048, 4096, 16384, 32768, 65536
So each number is like a true/false statement on the server side. So if the first 3 items, and only the first 3 items are marked "true" on the server side, the web service will return a 7. Or if all 14 items above are true, I would still get a single number back from the web service which is is the sum of all those numbers.
What is the best way to handle the number I get back to find out which items are marked as "true"?
© Stack Overflow or respective owner