Skip to content

Instantly share code, notes, and snippets.

View wwmoraes's full-sized avatar
🎯
Focusing

William Artero wwmoraes

🎯
Focusing
View GitHub Profile
@bassx
bassx / BWAND.applescript
Created March 28, 2012 15:16
AppleScript Handler: bitwise AND operator
(* __int1 : integer
* __int2 : integer
* Integers are from 0 till 2 ^ 31 - 1. When integers become greater than 2 ^ 31 then they will become a real and the handler wont't work.
*)
on BWAND(__int1, __int2)
set theResult to 0
repeat with bitOffset from 30 to 0 by -1
if __int1 div (2 ^ bitOffset) = 1 and __int2 div (2 ^ bitOffset) = 1 then
set theResult to theResult + 2 ^ bitOffset