In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

bitwise triks tests by Grant Skinner @FITC Tokyo

GrantSkinner FITC TOKYO session
http://gskinner.com/talks/quick/#48
bitwise tricks
val = num|0; //floor positive nums
val =num+0.5|0; // round pos nums
val =num>>1; //divide by 2 &~floor
if(++count&1){} //alternation
Get Adobe Flash player
by Murai 28 Nov 2009
/**
 * Copyright Murai ( http://wonderfl.net/user/Murai )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vIEY
 */

// forked from Murai's Math.random() * Number >> 0
// forked from Murai's 0 to .5 to 0
// forked from Murai's Math.random() - Math.random() 

//GrantSkinner FITC TOKYO session
//http://gskinner.com/talks/quick/#48
//
//bitwise tricks
//
//val = num|0; //floor positive nums
//val =num+0.5|0; // round pos nums
//val =num>>1; //divide by 2 &~floor
//if(++count&1){} //alternation

package {
    import flash.display.*;
    import flash.text.*;
    /*
        @author Takashi Murai(KAYAC)
    */
    [SWF(width="400", height="400", frameRate="24", backgroundColor="#FFFFFF")]
    
    public class Main extends Sprite {
        private var txt:TextField;
        private var i:uint=0;
        private var n:Number;
     
        public function Main() {
            init();         
        }
         
         public function init():void{
             txt = new TextField();
             txt.width = 400;
             txt.height = 400;
             addChild(txt);
             
             txt.appendText("val = num|0; //floor positive nums\n");
             while(++i%5){
                 n=Math.random()*100;
                 txt.appendText("n|0 = "+(n|0)+"\n");
             }
             
             txt.appendText("\nval = num+0.5|0; // round pos nums\n");
             while(++i%5){
                 n=Math.random()*100;
                 txt.appendText("n+0.5|0 = "+(n+0.5|0)+"\n");
             }
           
             txt.appendText("\nval = num>>1; //divide by 2 &~floor\n");
             while(++i%5){
                 n=Math.random()*100;
                 txt.appendText("n>>1 = "+(n>>1)+"\n");
             }
             
             txt.appendText("\nif(++count&1){} //alternation\n");
             n=0;
             while(++i%5){
                 txt.appendText("Boolean(++n&1) = "+Boolean(++n&1)+"\n");
             }
         }
         
        
    }
}