Skip to content

Instantly share code, notes, and snippets.

@honzabrecka
Created May 6, 2013 16:48
Show Gist options
  • Save honzabrecka/5526353 to your computer and use it in GitHub Desktop.
Save honzabrecka/5526353 to your computer and use it in GitHub Desktop.
var f:String;
var a:String = "a";
f = a || "b";
trace(f);
trace(2.53433 >> 0);
for (var i:int = 0; i < 9; i++)
trace(int(i / 3), (i / 3) >> 0);
const A:int = 1;
const B:int = 2;
const C:int = 4;
const D:int = 8;
const E:int = 16;
const F:int = 32;
const G:int = 64;
const H:int = 128;
var flags:int = 0;
function plus(flag:int):void
{
//if (!has(flag))
flags |= flag;
}
function minus(flag:int):void
{
//if (has(flag))
flags &= ~flag;
}
function has(flag:int):Boolean
{
return (flags & flag) == flag;
}
function test():void
{
trace(flags.toString(2), has(A), has(B), has(C), has(D), has(E), has(F), has(G), has(H));
}
test();
plus(B);
test();
minus(B);
test();
plus(C);
plus(F);
test();
trace(int(60 << 0).toString(2), int(13).toString(2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment