/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var myNumber:Number = 123.4597890; trace(roundDecimals(myNumber, 2)); function roundDecimals(num:Number, numDecimalPlaces:int):Number { return Math.round(num * Math.pow(10, numDecimalPlaces) ) / Math.pow(10, numDecimalPlaces); } // OUTPUT // 123.46