ios千分位和小数精度位数处理
- (NSString *)formatDecimalNumber:(NSString *)string {
if (!string || string.length == 0) {
return string;
}
NSNumber *number = @([string doubleValue]);
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
formatter.positiveFormat = @"###,##0.000";
NSString *amountString = [formatter stringFromNumber:number];
return amountString;
}
NSString *string = @"122234364.23234";
NSString *s1 = [self formatDecimalNumber:string];
NSLog(@"%@", s1); # 122,234,364.232