iOS 保留小数点两位 不四舍五入
2018-05-26 本文已影响45人
_秃头少女_
NSNumber *number = @(1.9999);
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setPositiveFormat:@"###0.00"];
formatter.roundingMode = NSNumberFormatterRoundDown;
formatter.maximumFractionDigits = 2;
NSLog(@"%@", [formatter stringFromNumber:number]);
``