> here is what I  
> would like to be able to do.
> 
> SetBit(mything,<whichbit>,<1 or 0>)
> GetBit(mything,<whichbit>) = boolean? 1/0

Bitwise operators are indeed confusing, here are a few functions that I
picked up somewhere along the way that should help:

Sub BitSet(ByRef Extends Map as Integer, bit as Integer)
  map=Bitwise.BitOR(map,pow(2,bit))
  
  'Use: Target.BitSet(WhichBit)
  'Sets WhichBit in Target

End Sub


Sub BitClear(ByRef extends bitMap as integer, bit as Integer)
  
  Bitmap=BitWise.BitAnd(BitMap,BitWise.OnesComplement(pow(2,bit)))
  
  'Use: Target.BitClear(WhichBit)
  'Clears WhichBit in Target

End Sub


Function BitTest(Extends bitMap as integer, bit as integer) As Boolean
  Return Bitwise.BitAnd(bitMap,pow(2,bit))>0
  
  'Use: Target.BitTest(WhichBit)
  
  'As in: If Target.BitTest(2) then Bit 2 is set

End Function


- John


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to