代码改变世界

How to not show unnecessary zeros when given integers but still have float answers when needed

2014-04-11 18:54  三戒1993  阅读(110)  评论(0编辑  收藏  举报

    NSString *str = [NSString stringWithFormat:@"%g",12.10];

    NSLog(@"str = %@",str);

输出:

str = 12.1

http://stackoverflow.com/questions/19667918/how-to-not-show-unnecessary-zeros-when-given-integers-but-still-have-float-answe

http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html

版权声明:本文为博主原创文章,未经博主允许不得转载。