flash on 2014-7-16
/**
* Copyright k-lock ( http://wonderfl.net/user/k-lock )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/j6vl
*/
package {
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
var number:Number = 10.98813311;
trace(setPrecision(number,0));
trace(setPrecision(number,1));
trace(setPrecision(number,2));
}
private function setPrecision(number:Number, precision:uint):Number {
precision = Math.pow(10, precision);
return Math.round(number * precision)/precision;
}
}
}