Z
zirconx
I'm trying to understand how the bitwise AND can be used. I've read
about what it does but am having trouble applying it practically. I'm
working on a system that somebody else wrote and they make use of a
MODE flag that gets passed in. They then compare the mode flag against
a hard coded value using bitwise AND, and then show or don't show
certain features based on the mode. Example pseudocode:
if (mode & 1) do something
if (mode & 4) show this control
if (mode & 10) show this label
The values that mode is compared to include: 4, 8, 9, 10, 12, 14
I've been doing some testing and writing out the result of the bitwise
ANDs, and I'm not seeing a useful pattern. Sometimes it returns true
and sometimes false, I can't see how this is really being used.
Any tips appricated.
about what it does but am having trouble applying it practically. I'm
working on a system that somebody else wrote and they make use of a
MODE flag that gets passed in. They then compare the mode flag against
a hard coded value using bitwise AND, and then show or don't show
certain features based on the mode. Example pseudocode:
if (mode & 1) do something
if (mode & 4) show this control
if (mode & 10) show this label
The values that mode is compared to include: 4, 8, 9, 10, 12, 14
I've been doing some testing and writing out the result of the bitwise
ANDs, and I'm not seeing a useful pattern. Sometimes it returns true
and sometimes false, I can't see how this is really being used.
Any tips appricated.