我收到错误#1008,但为了让事情有效,我需要添加什么?
private function rounding()
{
var originalNumber:Number = 2.97849382;
var rounded:Number = 2;
//just calculating by ones, which gives 2.98. if by two you would get 2.9785
trace("The original number was " +originalNumber+ " Rounded to " +rounded+ " digits, the number is "
+round(2.97849382, 1));
}
private function round(num:Number, precision:int):Number//using perameters to get info that is passed to them
{
var decimalPlaces:Number = Math.pow(100, precision);//change the number here to change the decimal place
return Math.round(decimalPlaces * num) / decimalPlaces;//calculating the answer, and returning the answer to the problem
}