- (void)viewDidLoad {
[super viewDidLoad];
double a = 1234355;
double b = 324546;
NSString *strA = [self formatNumberDecimalValue:a];
NSString *strB = [self formatNumberDecimalValue:b];
NSLog(@"%@---%@",strA,strB);
}
- (NSString *)formatNumberDecimalValue:(double)value {
NSString * string = [NSNumberFormatter localizedStringFromNumber:[NSNumber numberWithLongLong:value]
numberStyle:NSNumberFormatterDecimalStyle];
return string;
}
打印结果:1,234,355---324,546
网友评论