Finally another snippet!
I use this little function to check if a number is present in a number (Magic numbers)... Magic numbers are powers of 2 (like 16, 32, 64 etc.) which can be added BitORed together to form a magic number...
; #FUNCTION# ====================================================================================================================
; Name ..........: IsMgcNumPresent
; Description ...: Checks if a number is a present in a number (Magic numbers aka Powers of 2)
; Syntax ........: IsMgcNumPresent($iNumber, $iMagicNumber)
; Parameters ....: $iNumber - Number to check if it exists in $iMagicNumber.
; $iMagicNumber - The number which might contain $iNumber.
; Return values .: Success: True
; Failure: False
; Author ........: Damon Harris (TheDcoder)
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://bit.ly/IsMgcNumPresentForAutoIt
; Example .......: Yes, see below.
; ===============================================================================================================================
Func IsMgcNumPresent($iNumber, $iMagicNumber)
Return BitAND($iMagicNumber, $iNumber) = $iNumber
EndFunc
; Example
Global Const $NUMBER = 32
Global Const $MAGIC_NUMBER = BitOR(32, 64)
ConsoleWrite(@CRLF)
ConsoleWrite('+> Is ' & $NUMBER & ' present in ' & $MAGIC_NUMBER & '?... Its ' & IsMgcNumPresent($NUMBER, $MAGIC_NUMBER) & @CRLF)
ConsoleWrite(@CRLF)
UPDATE: I have moved this snippet to Gist, I will no longer maintain this version! please check for updates in the Gist itself!
Enjoy, TD