Bitmask Deciphering UDF
Keywords: bitmask deciphering listbits UDF
Question:
How do you decipher what a bitmask value is (what bits are set)?Answer:
#DefineFunction ListBits(bitmask) bitstring = "" bit = 1 While bitmask ;while there's still a bitmask value If bitmask & bit ;check bit bitstring = StrCat(bitstring, bit, @CRLF) bitmask = bitmask & ~bit ;decrement working bitmask number by existing byte increments Endif bit = bit * 2 ;increment byte EndWhile Return (bitstring) #EndFunction bitmask = 10776 ;bitmask = -1610612736 bitstring = ListBits(bitmask) Message("Bits in bitmask", bitstring)
Article ID: W14985