iOS & currencies around the world

Creating an app, handling currencies on the iPhone seemed to be a nice job regarding locales, NSNumberFormatter, etc in Objective-C. But some minutes later I found myself in the hell of currencies.

First things first: Entering amount in my app is done by entering the cent-amount. So entering "123" will result in "1,23€", pressing backspace you'll get "0,12€". Easy peasy. Formatting the number for display is done by a NSNumberFormatter:

NSNumberFormatter *_currencyFormatter = [[NSNumberFormatter alloc] init];
[_currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[_currencyFormatter setCurrencyCode:@"EUR"];

No problem so far, using EUR or USD, but let's go to Switzerland. Quoting the Wikipedia:

one-Rappen coins continued to be struck until 2006 and were demonetised in 2007

NSNumberFormatter knows this and will round CHF0.01 to CHF0.00, and CHF0.03 to CHF0.05. But using my method of entering amounts, you now can only enter amounts starting with 5. To bring back CHF0.01 you have to set the rounding increment as follows:

[_currencyFormatter setRoundingIncrement:[NSNumber numberWithFloat:0.01]];

Boom! Now you're ok with you Swiss friends (I'm not exactly sure, whether there other currencies with the same problem), but have you ever been to Japan, Korea or Iceland? No? More fun to come... currencies having no decimals! Not a big deal, but your app has to know about. These currencies do not use decimalisation:

NSSet *currenciesWithNoDecimals = [NSSet setWithObjects:@"BIF",@"BYR",@"CLP",@"DJF",@"GNF",@"ISK",@"JPY",@"KMF",@"KRW",@"PYG",@"RWF",@"VUV",@"XAF",@"XOF",@"XPF",nil];

Side note: Thinking about that, it seems a lot more sane to use integers for your money anyway. Doing this money-thing right, you'll have to bear the Arab world in mind. There are some currencies having three decimals. Quite weird, but I saw it by myself, stopping by the Muscat-Airport (Oman) on my trip to Thailand. So this list my help you:

NSSet *currenciesWithThreeDecimals = [NSSet setWithObjects:@"BHD",@"IQD",@"JOD",@"KWD",@"LYD",@"OMR",@"TND", nil];

The currency codes are defined in ISO4217, and the corresponding wikipedia article lists all the codes and the number of decimals for each currency. Scrolling through the list made me taken aback: between 0, 2 and 3 there a two row with 0.7. Madagascar and Mauritania are splitting their money by five and are the only countries in the world not using the decimal system in this field. As Apple doesn't support it in NSLocale, I can get over not supporting this in my app, too. But I see myself being in one of these countries, sitting on my laptop and retrofitting this feature.