Bitwise AND Comparison

Results 1 to 2 of 2

Thread: Bitwise AND Comparison

  1. #1
    Join Date
    Dec 1969

    Default Bitwise AND Comparison

    I have an Access Database with an integer field called GroupType. I want to execute a query that does a bitwise AND comparison to the value in GroupType. Unfortunately, I’ve done some research and that function is not built into the Access database language.<BR><BR>I was able to do a workaround within the database by adding a function called BitAnd in the module section.<BR><BR>My problem is that the function only works when executed within the database. When I execute the function from my ASP.NET page, I get an error that BitAnd is not a recognizable function.<BR><BR>I tried adding the function in the ASP.NET page, too, but that doesn’t work either.<BR><BR>Any suggestions on executing my bitwise AND comparison via a query from an APS.NET page?<BR><BR>Please advise.<BR><BR>Thanks,<BR>Jason

  2. #2
    Join Date
    Dec 1969

    Default It's not too hard to hack one together...

    For example:<BR><BR>SELECT * FROM table WHERE ( (cnt4) MOD 2 ) &#060;&#062; 0<BR><BR>The is the integer divide operator (available in Access and in VBScript).<BR><BR>So (cnt4) is the same as doing (cnt &#062;&#062; 2) [shifting cnt two bits to the right].<BR><BR>And then doing MOD 2 is the same thing as getting just the low order bit. <BR><BR>So that code is the same as C/C++/Java/JavaScript cod that does<BR> cnt & 4<BR><BR>You could test patterns of bits, too, by combining the integer division and MOD.<BR><BR>Say you wanted to do<BR> fld & 0x18<BR>you&#039;d just do<BR> ( (fld 8) MOD 3)<BR><BR>If you want to test disjoint bits, then you&#039;ll have to use a pair (or more) of those kinds of expressions.<BR><BR>Maybe:<BR> fld & 0x42<BR>so you&#039;d need<BR> ( (fld 2) MOD 2)<BR>and<BR> ( (fld 64 ) MOD 2)<BR><BR>etc.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts