#pragmamark - 判断字符串是否为整型
- (BOOL)isPureInt:(NSString *)string{
NSScanner* scan = [NSScanner scannerWithString:string];
int val;
return[scan scanInt:&val] && [scan isAtEnd];
}
#pragmamark - 把大长串的数字做单位处理
- (NSString *)changeAsset:(NSString *)amountStr
{
if(amountStr && ![amountStr isEqualToString:@""])
{
NSInteger num = [amountStr integerValue];
if(num >=1000000000000)
{
NSString *str = [NSString stringWithFormat:@"%ld",num/1000000000000];
return[NSString stringWithFormat:@"%@万亿",str];
} elseif(num >=100000000)
{
NSString *str = [NSString stringWithFormat:@"%ld",num/100000000];
return[NSString stringWithFormat:@"%@亿",str];
} elseif(num >=10000000)
{
NSString *str = [NSString stringWithFormat:@"%ld",num/10000000];
return[NSString stringWithFormat:@"%@千万",str];
}elseif(num >=10000)
{
NSString *str = [NSString stringWithFormat:@"%ld",num/10000];
return[NSString stringWithFormat:@"%@万",str];
}
}
return amountStr;
}
网友评论