// 将小数保留两位小数 并且后面的零不显示
NSString *strMoney = [NSString stringWithFormat:@"%.2f",money];
NSDecimalNumber *num1 = [NSDecimalNumber decimalNumberWithString:strMoney];
NSLog(@"%@",num1);
// 将小数保留两位小数 并且后面的零不显示
NSString *strMoney = [NSString stringWithFormat:@"%.2f",money];
NSDecimalNumber *num1 = [NSDecimalNumber decimalNumberWithString:strMoney];
NSLog(@"%@",num1);
本文标题:oc小数精度问题
本文链接:https://www.haomeiwen.com/subject/gzfcdxtx.html
网友评论