135-1821-9792

IOS字符串的Format可以对数值四舍五入

NSLog(@"%@", [NSString stringWithFormat:@"%.0f", 1.0003]);
NSLog(@"%@", [NSString stringWithFormat:@"%.0f", 1.9003]);
NSLog(@"%@", [NSString stringWithFormat:@"%.0f", 1.5003]);
NSLog(@"%@", [NSString stringWithFormat:@"%.0f", 1.4003]);
// 输出
1
2
2
1

分享文章:IOS字符串的Format可以对数值四舍五入
当前地址:http://kswsj.com/article/pjpjjg.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号