-
(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:@"."];
if (range.length >0 ) {
NSString * result = [formatterString substringFromIndex:range.location];
if (result.length >= 4) {
formatterString = [formatterString substringToIndex:formatterString.length - 1];
}
}return formatterString;
}
网友评论