Reputation: 48696
I am using Cocoa's NSNumberFormatter
to represent money, which works very well for normal amounts. I am now at a situation where I want to represent very large amounts of money in a more human readable way once money starts accumulating more than a billion, similar to the way games like Adventure Capitalism represent money.
For example, I would like to represent a 500,100,000,000$ as 500,100B$ etc. Is there a plugin or an easy way of doing this, other than creating a manual function that would handle all these cases?
Upvotes: 1
Views: 128
Reputation: 16660
NSNumberFormatter
does not support unit prefixes. (NSByteCountformatter
does, but this doesn't help you.) Additionally your prefixes aren't scientific unit prefixes, i. e. you want t have a B for billion instead a G for giga.
You have to do this your own way. You can do this simply by having an array of prefixes and then dividing for each 1,000. However, you have to localize that and I'm pretty sure, that you do not want that. I. e. in Germany we use Mrd for billion, because it is "Milliarde". And Germany is still a western country. I have no idea, what they do in China.
Upvotes: 2