开发者

Formatting a float number inside a Mutable string

开发者 https://www.devze.com 2023-02-12 11:50 出处:网络
I have a couple of floats and they all are stored in a mutable string. But while displaying them it\'s showing 2011.00000 inspite of 2011 so i want it to format it.

I have a couple of floats and they all are stored in a mutable string. But while displaying them it's showing 2011.00000 inspite of 2011 so i want it to format it. Any suggesti开发者_JAVA技巧ons.

Thanks


NSString* str = [NSString stringWithFormat:@"%.f", float_number];


Could you just put them into floats and then use a stringWithFormat(@"%f4.0", ?


Use

NSString* sa = [NSString stringWithFormat: @"%0.0f", 22323.4342];
0

精彩评论

暂无评论...
验证码 换一张
取 消