-(NSString*)removeFloatAllZero:(NSString*)string
{ NSString * testNumber = string;
NSString * outNumber = [NSString stringWithFormat:@"%@",@(testNumber.floatValue)]; // 价格格式化显示
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = kCFNumberFormatterDecimalStyle;
NSString *formatterString = [formatter stringFromNumber:[NSNumber numberWithFloat:[outNumber doubleValue]]]; NSRange range = [formatterString rangeOfString:@"."]; //现获取要截取的字符串位置
NSLog(@"--------%lu",(unsigned long)range.length); if (range.length>) { NSString * result = [formatterString substringFromIndex:range.location]; //截取字符串 if (result.length>=) { formatterString=[formatterString substringToIndex:formatterString.length-];
} } NSLog(@"Formatted number string:%@",formatterString); NSLog(@"Formatted number string:%@",outNumber);
// 输出结果为:[1223:403] Formatted number string:123,456,789 return formatterString;
}