I would like to format integers as professional looking currency strings. For example:
1200000 -> $1.2 million
456 -> $456.00
Do you know a good library for this, ideally with localization to handle European formats.
I would like to format integers as professional looking currency strings. For example:
1200000 -> $1.2 million
456 -> $456.00
Do you know a good library for this, ideally with localization to handle European formats.
locale.currency()
can handle the number bits, but I've not seen a module for the word part.
Such formatting seems reasonable in some limited uses. But, should 1200000 be formatted as 1.2 million or 1.20 million? And isn't 456 more friendly as $456 (without the cents)?
Adding cents to large precise numbers is common in sweepstakes mailers (Ed McMann says you can win $12,000,000.00).
It seems a careful specification of what the proper output for different kinds of numbers is the larger problem. Once that's done, it would be pretty straightforward to write a formatting function.