How well to print the float value?

Example:

I have a float value such as 1294322.0000000 and I want to print it to a label, for example:

1.294.322

Thus, in every thousandth position, there is one dot between them. I bet you know what I mean. I don’t know which English words are for this.

Or, for example, I have a float like this: 15.29, then it should look like "15.29".

Or a float like 1422 which should look like 1.422

If there is no floating point precision after ",", I don't want to print it. For example:

4.311 is correct, but 4.311.00 is not required.

Are there any useful classes that help with these number formatting problems in objective-c / iphone sdk / cocoa touch?

+2


source to share


1 answer


Take a look at NSNumberFormatter .



+3


source







All Articles