- (NSString*)notRounding:(id)priceafterPoint:(NSInteger)position {
//生成format格式
NSString*format = [NSStringstringWithFormat:@"%%.%ldf",(long)position];
CGFloatvalue =0.;
//string 和 number 兼容
if([pricerespondsToSelector:@selector(doubleValue)]) {
value = [pricedoubleValue];
}
NSString*number = [NSStringstringWithFormat:format,value];
// 去掉小数点后面的无效0
NSString * outNumber = [NSString stringWithFormat:@"%@",[[NSDecimalNumber decimalNumberWithString:number] stringValue]];
returnoutNumber;
}
网友评论