Many languages, such as .NET languages and Java come with a currency formatting facility built-in. What they do is format a number using a culture-specific number format and add the culture's currency symbol.
The problem here is that the number format is strongly coupled to the currency symbol. In practice the number format should be the correct one for the language of the surrounding text, while the currency symbol should be for the currency being talked about. For example, you wouldn't use American thousand separators when talking about US Dollars in a document that's in German.
Can you think of a practical use for this kind of currency formatting functions, or do they exist just to impress money-oriented management people?
At least in .NET the number format is tied to a culture, not the symbol. The default currency symbol is the primary one associated with that culture. The symbol can be overridden as required.
Like your example, if I'm embedding a currency value in a string then I use the string's culture for the format, but override the currency symbol appropriately. The rest of the formatting is left as-is.
On the other hand if I'm doing a report all of the values are formatted using the same culture. I normally use the ISO 3-character codes instead of currency symbols in this case, especially if more than 2 currencies are involved, to avoid font issues.
Ryan's answer to another question describes the what and how Best Practices for currency formatting in C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With