Question
Binary Flags
I'm making some games where the user needs to select/check
several different boxes and leave several others unchecked. I have
put it in a binary "flag" what the correct answer is. That is:
11010
Reading from the rights side of the number, that would be box 1 unchecked, box 2 checked, box 3 unchecked, box 4 checked, and box 5 checked. (There may be more boxes, but they are all unchecked and leading zeros don't show.)
I've worked out th different bitwise operations to tell me if they are correct, incorrect, or a mixture. But I'm trying to figure out how to give feed back at the end. Basically I want to highlight all the ones that should have been checked and hide all the ones that should not have been checked, i.e. if there is a zero in the flag hide the corresponding box and if there is a one put a highlight color on the box.
How does one quickly read through a binary number and see which are ones and which are zeros?
11010
Reading from the rights side of the number, that would be box 1 unchecked, box 2 checked, box 3 unchecked, box 4 checked, and box 5 checked. (There may be more boxes, but they are all unchecked and leading zeros don't show.)
I've worked out th different bitwise operations to tell me if they are correct, incorrect, or a mixture. But I'm trying to figure out how to give feed back at the end. Basically I want to highlight all the ones that should have been checked and hide all the ones that should not have been checked, i.e. if there is a zero in the flag hide the corresponding box and if there is a one put a highlight color on the box.
How does one quickly read through a binary number and see which are ones and which are zeros?