Ok, so I’ve read quite a bit on formatting and I’m good to go on currency, numbers with commas, etc.
I’ve been trying for awhile to format a percent number and I’ve gotten relatively close to where I want to be:
public static function percent(n:Number):String {
//Converts the argument to a string with the percentage symbol
var output:String = Math.ceil(n*100).toString() + "%";
//Returns the reformatted percentage
return output;
}
The problem here is that I need to be able to set precision and I keep messing it up when I try to write something… here’s an example:
Number: 0.203948278358292
Result with the above code: 20%
Desired Result: 20.39%
Can anyone help me with this?