Limit a double to two decimal places without trailing zeros
问题 I read this and that. I want this exactly: 1.4324 => "1.43" 9.4000 => "9.4" 43.000 => "43" 9.4 => "9.40" (wrong) 43.000 => "43.00" (wrong) In both questions the answers points to NSNumberFormatter . So it should be easy to achieve, but not for me. - (void)viewDidLoad { [super viewDidLoad]; UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 20)]; NSNumberFormatter *doubleValueWithMaxTwoDecimalPlaces = [[NSNumberFormatter alloc] init]; [doubleValueWithMaxTwoDecimalPlaces