Format a Number to a String - With decimals and thousands separator


/ Published in: ActionScript 3
Save to your folder(s)

Format a number so it is more humanly readable. It allows for setting the number of decimal places (inc. adding 0000s to the end) and separating thousands with a comma.

Example usage:

trace(numberFormat(1234.695, 2, true, false));
// Output: 1,234.70

trace(numberFormat(16000000, 0, false, false));
// Output: 16,000,000

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.