标签: iphone objective-c ios5
可能重复: Limit a double to two decimal places
我想在Objective C中以特定格式显示数字。在这里,我只想以两种精度显示数字。
假设我有25.5之类的数字;
然后我想要下面给出的节目号。
25.5 => 25.50
答案 0 :(得分:10)
替换为
taxLbl.text = [NSString stringWithFormat:@"%.2f", [sum doubleValue]];
答案 1 :(得分:1)
您可能想查看NSNumberFormatter class reference。