Reputation: 609
I have distance in following format.
36.5067714083419
I want two character after occurrence of dot "." So the above String must look like
36.50
Thanks
Upvotes: 1
Views: 121
Reputation: 6394
Why are you using an NSString
? By judging the name and the value of the variable I would suggest using a float
. Then you can just do the following:
NSString* formattedNumber = [NSString stringWithFormat:@"%.02f", myFloat];
Upvotes: 1