rounding test

by grapefrukt
♥0 | Line 19 | Modified 2010-11-18 02:08:17 | MIT License
play

ActionScript3 source code

/**
 * Copyright grapefrukt ( http://wonderfl.net/user/grapefrukt )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fNO9
 */

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {

            var tf:TextField = new TextField();
            tf.height = 300;
            addChild(tf);
            
            tf.appendText(Math.round( .51     ).toString() + "\n");            
            tf.appendText(Math.floor( .51 + .5).toString() + "\n");
            
            tf.appendText(Math.floor(-.51 + .5).toString() + "\n");
            tf.appendText(Math.round(-.51     ).toString() + "\n");
            
            tf.appendText(Math.round( .49     ).toString() + "\n");            
            tf.appendText(Math.floor( .49 + .5).toString() + "\n");
            
            tf.appendText(Math.floor(-.49 + .5).toString() + "\n");
            tf.appendText(Math.round(-.49     ).toString() + "\n");
           
        }
    }
}