iphone - How to format a number such a way that there is always one fractional digit? -


For example, I have float values:

0.2 1.5 2.0 3.0 10.0 52.5 60.0

In any case, I really want a fractional number even if the number is exactly 1, then I have to show it as 1.0

I have a NSNumberFormatter like this Tried to set up, but it does not work:

  NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init]; [Formator setAllejeschoskakeAspirator: No]; [Former setAlowflats: Yes]; [Formatter setbihar: NSNumberFormatterBehavior10_4]; [Formator cetiumine fractionation: 1]; [Formator set from genuine dygets: yes]; [Formator Senthminum Gupta Diets: 2]; [Setter Settlement Style: kCFNumberFormatterDecimalStyle]; It shows 0.2, 5.0, 5.5, 9.0, 

, but when it reaches 10, it is 10, 10.3, 11, 11.9, 15, Will show ... and similarly Is not that something NSNumberFormatter can do?

Try it?

NSString * F = [NSString stringWithFormat: @ "% .01f", (float) 10];


Comments