Re: and_bits() usage
- Posted by jemima Oct 12, 2009
- 1078 views
euphoric said...
Okay, so for testing ONE or more bits, you can do this:
my_val = 10 test_val = 2 if and_bits( my_val, test_val ) then --... end if
Do we all agree?
no!
The above is true for testing ONE or ANY of the specified bits
(which in your example was just the one bit anyway,
and I suspect you meant ANY when you said "more").
Testing that ALL the specified bits are set is and_bits(flag,mask)=mask
(but as said you don't need the =mask if it is just one bit).
Testing that NONE of the specified bits are set is not and_bits(flag,mask).
HTH