Re: and_bits() usage

new topic     » goto parent     » topic index » view thread      » older message » newer message
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? smile

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu