Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why some cultures round currency decimals by default?

I have noted that when using the framework function string.Format to format currency values, in some cultures this function rounds the decimals by default. For example, when working with Malaysian ringgits:

CultureInfo culture = new CultureInfo("ms-MY");
someLabel.Content = string.Format(culture,"{0:C}", 1.64m);

Outputs: RM2

However when working with other currencies, like USD, euros or others, you get the original value, for example:

CultureInfo culture = new CultureInfo("sv-SE");
someLabel.Content = string.Format(culture,"{0:C}", 1.64m);

Outputs: 1.64kr

I know that I can specify the number of decimals in the CultureInfo class, but the question is, why this happens with some currencies but not with others? It is expected that some currencies are rounded by default?

like image 533
Alejandro Martin Avatar asked Aug 17 '15 08:08

Alejandro Martin


People also ask

Do all countries have decimal currency?

Today, only two countries have non-decimal currencies: Mauritania, where 1 ouguiya = 5 khoums, and Madagascar, where 1 ariary = 5 iraimbilanja.

Do all currencies money used around the world have two decimal places?

Most currencies have two decimals. Some currencies do not have decimals, and some have three decimals. For example: 10 GBP: GBP has two decimals, so in minor units submit an amount of 1000.

Does Japanese yen have decimal places?

Not all world currencies have decimal places. Two examples are the Japanese Yen (JPY) and the South Korean Won (KRW). Salesforce Billing does not appear to properly round values to accommodate this.

Which countries have 3 decimal places?

Yes, those countries that uses Dinar as their currencies have more than two decimal digits. Their subdivision is 3 decimal digits instead of 2. Algeria, Bahrain, Iraq, Jordan, Kuwait, Libya and Tunisia. Those in Europe that uses Dinar are exception to the rule.


1 Answers

From The Currency "C" Format Specifier

If the precision specifier is omitted, the default precision is defined by the CurrencyDecimalDigits property.

And this ms-MY culture has 0 as a CurrencyDecimalDigits property. That's why it doesn't have any decimal places in the result.

enter image description here

As a solution, you can use precision specifier as;

CultureInfo culture = new CultureInfo("ms-MY");
someLabel.Content = string.Format(culture,"{0:C2}", 1.64m); // RM1.64

Why some currencies are rounded (or they have this property set to 0, if you prefer), but not others. Is there some rule for that?

Honestly, I don't know. But I made some research and here what I found;

Malaysia uses ringgit as a currency. It is divided into 100 sen. And with it's third series, there were be only 4 coins as; 5 sen, 10 sen, 20 sen, 50 sen.

With previous (second) series;

As of 1 April 2008, a rounding mechanism of prices to the nearest 5 sen, applied to the total bill only, is in force, which was first announced in 2007 by Bank Negara Malaysia, in an attempt to render the 1 sen coin irrelevant.

Article: http://www.thestar.com.my/story/?file=%2f2007%2f11%2f14%2fnation%2f19460993&sec=nation&focus=1

How it works

This image kind of useful about telling you can't divide a RM by 100 because it will not be meaningful. By the way, I have to say this 0 value does not match with ISO 4217 which specifies currency designators. From Active Codes section, you can see this MYR has 2 decimal digits in this standard.

This XML file from currency-iso.org says this as well;

<CcyNtry>
  <CtryNm>MALAYSIA</CtryNm>
  <CcyNm>Malaysian Ringgit</CcyNm>
  <Ccy>MYR</Ccy>
  <CcyNbr>458</CcyNbr>
  <CcyMnrUnts>2</CcyMnrUnts>
</CcyNtry>

Also from Contemporary non-decimal currencies section in Non-decimal currency page;

Today only two countries in the world use non-decimal currencies. Both are in Africa. These are Mauritania (1 ouguiya = 5 khoums) and Madagascar (1 ariary = 5 iraimbilanja). However these are only theoretically non-decimal, as in both cases the value of the main unit is so low that the sub-unit is too small to be of any practical use and coins of the sub-unit are no longer used

Check the other sections of this page by the way, there are really useful information about that.

This is kind of complicated in my opinion. I also connected to .NET Team as well. I will update this answer when I get feedback from them.

UPDATE 18/08/2015

As Tarek mentioned, this CurrencyDecimalDigits property of this my-MY culture changed as 2 in Windows 10.

And Shawn Steele (Windows and .NET Framework globalization API expert) suggests as;

Probably formatting currencies using Windows.Globalization and doing it by currency might be a better idea.

UPDATE 21/02/2016

Looks like this happens on Windows Server 2012 R2 again. I connected to .NET Team about this and they respond as we can use Locale Builder to create a new custom culture or edit an existing culture to change this ICURRDIGITS settings as 2.

like image 55
Soner Gönül Avatar answered Sep 29 '22 07:09

Soner Gönül