我的应用程序中有简单的计算
-(IBAction)calculate {
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
[nf setRoundingMode: NSNumberFormatterRoundHalfUp];
[nf setMaximumFractionDigits: 2];
float value1 = [[nf numberFromString: textField1.text] floatValue];
float value2 = [[nf numberFromString: textField2.text] floatValue];
float x = value1 * value2 / 100;
label2.text = [nf stringFromNumber: [NSNumber numberWithFloat: x]];
[nf release];
}
现在,当我计算结果看起来像这样:,75
或64,5
我需要我的结果如下所示:0,75
或64,50
我的问题是小数点前或小数点后没有零